:root {
  --ink: #142a30;
  --ink-soft: #30464b;
  --muted: #69787b;
  --line: #d9dfdc;
  --line-strong: #bdc9c5;
  --paper: #f3f5f1;
  --surface: #ffffff;
  --surface-soft: #edf2ef;
  --deep: #0f3d44;
  --deep-2: #0a2d33;
  --teal: #008f91;
  --teal-dark: #006f73;
  --cyan: #13a9c4;
  --coral: #e76552;
  --green: #5b9247;
  --amber: #d99c2b;
  --red: #c94e45;
  --shadow: 0 12px 32px rgba(20, 42, 48, 0.08);
  --shadow-small: 0 4px 14px rgba(20, 42, 48, 0.07);
  --radius: 8px;
  --font-sans: "Manrope", sans-serif;
  --font-mono: "JetBrains Mono", monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  letter-spacing: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 0;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    linear-gradient(rgba(20, 42, 48, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(20, 42, 48, 0.025) 1px, transparent 1px);
  background-size: 32px 32px;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

button,
select,
input[type="range"],
input[type="radio"],
input[type="checkbox"] {
  cursor: pointer;
}

button:disabled,
select:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

a {
  color: inherit;
}

img {
  display: block;
  max-width: 100%;
}

svg {
  width: 1.1rem;
  height: 1.1rem;
  flex: 0 0 auto;
  stroke-width: 2;
}

[hidden] {
  display: none !important;
}

.container {
  width: min(1220px, calc(100% - 48px));
  margin-inline: auto;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 12px;
  left: 12px;
  padding: 10px 14px;
  color: #fff;
  background: var(--deep);
  border-radius: 4px;
  transform: translateY(-160%);
  transition: transform 160ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

:focus-visible {
  outline: 3px solid rgba(19, 169, 196, 0.38);
  outline-offset: 3px;
}

.phone-gate {
  display: none;
}

html.is-phone body {
  background: var(--deep-2);
}

html.is-phone .phone-gate {
  display: grid;
}

html.is-phone .desktop-app,
html.is-phone .skip-link,
html.is-phone .rename-dialog,
html.is-phone .noscript-message {
  display: none !important;
}

.phone-gate {
  min-height: 100svh;
  place-items: center;
  padding: 36px 22px;
  color: #f7fbf9;
  background-color: var(--deep-2);
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 26px 26px;
}

.phone-gate__content {
  width: min(100%, 440px);
}

.phone-gate__toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 28px;
}

.phone-gate__logo {
  width: 88px;
  height: 88px;
  margin-bottom: 0;
  padding: 7px;
  object-fit: contain;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.22);
}

.eyebrow,
.section-kicker {
  margin: 0;
  color: var(--teal);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}

.phone-gate .eyebrow {
  margin-bottom: 8px;
  color: #6edce0;
}

.phone-gate h1 {
  max-width: 390px;
  margin: 0;
  font-size: 2.25rem;
  line-height: 1.12;
}

.phone-gate__lead {
  margin: 18px 0 28px;
  color: #c8d7d7;
  font-size: 1.05rem;
}

.phone-steps {
  display: grid;
  gap: 0;
  margin: 0 0 24px;
  padding: 0;
  list-style: none;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.phone-steps li {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 12px;
  align-items: center;
  padding: 15px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.phone-steps li > span {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  color: var(--deep-2);
  background: #6edce0;
  border-radius: 50%;
  font-weight: 800;
}

.phone-steps p {
  margin: 0;
  color: #e5eeee;
}

.address-copy {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 8px 8px 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.07);
}

.address-copy code {
  overflow: hidden;
  color: #fff;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.copy-status {
  min-height: 22px;
  margin: 6px 0 0;
  color: #6edce0;
  font-size: 0.78rem;
  font-weight: 700;
}

.phone-gate__note {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  margin: 18px 0 0;
  color: #9db4b4;
  font-size: 0.76rem;
}

.phone-gate__note svg {
  margin-top: 1px;
  color: #6edce0;
}

.phone-product {
  margin-top: 36px;
  padding-top: 28px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.phone-product > img {
  display: block;
  width: min(100%, 220px);
  height: auto;
  margin: 0 auto 24px;
  border-radius: var(--radius);
}

.phone-product h2 {
  font-size: 1.4rem;
  line-height: 1.3;
}

.phone-product p,
.phone-product__features {
  color: #c8d7d7;
  font-size: 0.9rem;
}

.phone-ha {
  margin-top: 28px;
  padding: 20px;
  border: 1px solid rgba(110, 220, 224, 0.35);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.06);
}

.phone-ha h2 {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.3;
}

.phone-ha p:not(.eyebrow) {
  margin: 10px 0 16px;
  color: #c8d7d7;
  font-size: 0.88rem;
}

.phone-ha__button {
  width: 100%;
  color: var(--deep-2);
  background: #6edce0;
}

.phone-product__features {
  display: grid;
  gap: 16px;
  padding-inline-start: 20px;
}

.phone-product__features strong {
  color: #f7fbf9;
}

.phone-product__features p {
  margin: 4px 0 0;
}

.language-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  grid-column: 1 / -1;
  margin-top: 24px;
  font-size: 0.8rem;
}

.language-links a {
  color: #c8d7d7;
  text-underline-offset: 3px;
}

.language-links a[aria-current="page"] {
  color: #6edce0;
  font-weight: 800;
}

.site-header {
  position: sticky;
  z-index: 20;
  top: 0;
  border-bottom: 1px solid rgba(189, 201, 197, 0.78);
  background: rgba(243, 245, 241, 0.92);
  backdrop-filter: blur(16px);
}

.site-header__inner {
  display: flex;
  min-height: 70px;
  justify-content: space-between;
  align-items: center;
}

.brand {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  color: var(--ink);
  text-decoration: none;
}

.brand img {
  width: 42px;
  height: 42px;
}

.brand > span {
  display: grid;
  line-height: 1.05;
}

.brand strong {
  font-size: 0.96rem;
  font-weight: 800;
}

.brand small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
}

.site-actions {
  display: flex;
  gap: 16px;
  align-items: center;
}

.site-actions a {
  color: var(--ink-soft);
  font-size: 0.84rem;
  font-weight: 700;
  text-decoration: none;
}

.site-actions a:hover {
  color: var(--teal-dark);
}

.language-control {
  display: inline-flex;
  min-height: 38px;
  gap: 7px;
  align-items: center;
  padding: 0 8px 0 10px;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.72);
}

.language-control select {
  min-height: 34px;
  padding: 4px 22px 4px 4px;
  color: inherit;
  border: 0;
  background: transparent;
  font-size: 0.76rem;
  font-weight: 700;
}

.language-control select:focus {
  outline: 0;
}

.language-control--dark {
  color: #e9f3f2;
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.07);
}

.language-control--dark select {
  color: #fff;
}

.language-control--dark option {
  color: var(--ink);
  background: #fff;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.github-link {
  display: inline-flex;
  gap: 7px;
  align-items: center;
}

.site-actions .github-link--ha {
  min-height: 38px;
  padding: 0 12px;
  color: #fff;
  border-radius: 6px;
  background: var(--deep);
}

.site-actions .github-link--ha:hover {
  color: #fff;
  background: var(--teal-dark);
}

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
  gap: 44px;
  align-items: center;
  padding-top: 54px;
  padding-bottom: 38px;
  animation: reveal 480ms ease both;
}

.intro__copy {
  max-width: 850px;
}

.intro .eyebrow {
  margin-bottom: 10px;
}

.intro h1 {
  margin: 0;
  max-width: 780px;
  color: var(--ink);
  font-size: 2.5rem;
  line-height: 1.12;
}

.intro__copy > p:not(.eyebrow) {
  max-width: 680px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.intro__visual {
  display: grid;
  margin: 0;
  place-items: center;
}

.intro__device {
  width: min(100%, 380px);
  height: auto;
  justify-self: center;
  padding: 0;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.intro__product {
  aspect-ratio: 1;
}

.privacy-points {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 26px;
  margin-top: 23px;
}

.privacy-points span {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 700;
}

.privacy-points svg {
  width: 0.98rem;
  color: var(--teal);
}

.compatibility-notice {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 18px;
  padding: 17px 20px;
  color: #5d4111;
  border: 1px solid #e5c988;
  border-radius: var(--radius);
  background: #fff6dc;
}

.compatibility-notice svg {
  margin-top: 3px;
  color: var(--amber);
}

.compatibility-notice strong,
.compatibility-notice p {
  display: block;
  margin: 0;
}

.compatibility-notice p {
  margin-top: 2px;
  font-size: 0.86rem;
}

.connection-panel,
.tool-panel,
.ha-panel,
.logs-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-small);
}

.connection-panel {
  overflow: hidden;
  animation: reveal 480ms 80ms ease both;
}

.connection-panel__main {
  padding: 22px 24px;
}

.connection-heading,
.device-row,
.connection-panel__footer,
.known-devices__heading,
.tool-panel__header,
.logs-panel > header,
.rename-dialog header,
.rename-dialog footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.section-kicker {
  margin-bottom: 2px;
  font-size: 0.67rem;
}

.connection-heading h2,
.tool-panel__header h2,
.ha-panel h2,
.logs-panel h2,
.rename-dialog h2 {
  margin: 0;
  font-size: 1.12rem;
  line-height: 1.25;
}

.status-pill {
  display: inline-flex;
  min-width: 112px;
  gap: 8px;
  justify-content: center;
  align-items: center;
  padding: 7px 11px;
  color: #793731;
  border: 1px solid #ebc1bc;
  border-radius: 999px;
  background: #fff0ed;
  font-size: 0.72rem;
  font-weight: 800;
}

.status-pill__dot {
  width: 7px;
  height: 7px;
  background: var(--red);
  border-radius: 50%;
}

.status-pill[data-state="connecting"] {
  color: #67501d;
  border-color: #e7d39f;
  background: #fff8e4;
}

.status-pill[data-state="connecting"] .status-pill__dot {
  background: var(--amber);
  animation: pulse 1.1s ease infinite;
}

.status-pill[data-state="connected"] {
  color: #355e29;
  border-color: #bbd4b2;
  background: #edf7e9;
}

.status-pill[data-state="connected"] .status-pill__dot {
  background: var(--green);
}

.device-row {
  gap: 24px;
  margin-top: 20px;
}

.device-identity {
  display: flex;
  min-width: 0;
  gap: 12px;
  align-items: center;
}

.device-identity__icon,
.tool-panel__icon {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  place-items: center;
  color: var(--teal-dark);
  background: #e5f4f2;
  border-radius: 50%;
}

.device-identity > div {
  display: grid;
  min-width: 0;
}

.device-identity strong {
  overflow: hidden;
  font-size: 0.95rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.device-identity > div span {
  overflow: hidden;
  margin-top: 2px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.text-button,
.icon-button,
.button {
  border: 0;
  border-radius: 6px;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.text-button {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  padding: 7px 9px;
  color: var(--teal-dark);
  background: transparent;
  font-size: 0.74rem;
  font-weight: 800;
}

.text-button:hover:not(:disabled) {
  background: #e8f2ef;
}

.icon-button {
  display: inline-grid;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  place-items: center;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  background: var(--surface);
}

.icon-button:hover:not(:disabled) {
  color: var(--teal-dark);
  border-color: #9ec8c5;
  background: #edf7f5;
}

.icon-button--light {
  color: var(--deep);
  border: 0;
  background: #fff;
}

.button {
  display: inline-flex;
  min-height: 44px;
  gap: 9px;
  justify-content: center;
  align-items: center;
  padding: 10px 16px;
  font-size: 0.8rem;
  font-weight: 800;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button--primary {
  color: #fff;
  background: var(--deep);
  box-shadow: 0 5px 12px rgba(15, 61, 68, 0.16);
}

.button--primary:hover:not(:disabled) {
  background: var(--teal-dark);
}

.button--secondary {
  color: var(--deep);
  border: 1px solid #9fc5c0;
  background: #e8f4f1;
}

.button--secondary:hover:not(:disabled) {
  border-color: #72aaa5;
  background: #dcefeb;
}

.button--ghost {
  color: var(--ink-soft);
  border: 1px solid var(--line);
  background: #fff;
}

a.button {
  text-decoration: none;
}

.connect-button {
  min-width: 190px;
}

.button-spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

.is-loading .button-spinner {
  display: block;
}

.button.is-loading > svg {
  display: none;
}

.connection-panel__footer {
  gap: 20px;
  min-height: 52px;
  padding: 10px 24px;
  border-top: 1px solid var(--line);
  background: #f8faf8;
}

.toggle-control {
  display: inline-flex;
  gap: 9px;
  align-items: center;
  color: var(--ink-soft);
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
}

.toggle-control input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.toggle-control__track {
  position: relative;
  width: 34px;
  height: 19px;
  border: 1px solid #9eaaa7;
  border-radius: 999px;
  background: #bbc5c2;
  transition: background-color 160ms ease, border-color 160ms ease;
}

.toggle-control__track span {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 13px;
  height: 13px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 160ms ease;
}

.toggle-control input:checked + .toggle-control__track {
  border-color: var(--teal);
  background: var(--teal);
}

.toggle-control input:checked + .toggle-control__track span {
  transform: translateX(15px);
}

.toggle-control input:focus-visible + .toggle-control__track {
  outline: 3px solid rgba(19, 169, 196, 0.38);
  outline-offset: 3px;
}

.retry-message {
  margin: 0;
  color: var(--muted);
  font-size: 0.7rem;
}

.identification-tip {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 13px 24px;
  color: #43575b;
  border-top: 1px solid #cfe0dc;
  background: #edf7f4;
}

.identification-tip svg {
  margin-top: 2px;
  color: var(--teal-dark);
}

.identification-tip p {
  margin: 0;
  font-size: 0.74rem;
}

.known-devices {
  padding: 18px 24px 20px;
  border-top: 1px solid var(--line);
}

.known-devices__heading {
  gap: 20px;
}

.known-devices h3 {
  margin: 0;
  font-size: 0.82rem;
}

.known-devices__heading > span {
  color: var(--muted);
  font-size: 0.65rem;
}

.known-devices ul {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.known-device {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-width: 0;
  padding: 10px 10px 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fafbf9;
}

.known-device__identity {
  display: grid;
  min-width: 0;
}

.known-device strong,
.known-device small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.known-device strong {
  font-size: 0.72rem;
}

.known-device small {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.56rem;
}

.known-device__actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.known-device__actions button {
  min-height: 34px;
  padding: 6px 10px;
  color: var(--deep);
  border: 1px solid #a9c9c5;
  border-radius: 5px;
  background: #e8f4f1;
  font-size: 0.66rem;
  font-weight: 800;
}

.known-device__actions .known-device__remove {
  display: grid;
  width: 34px;
  min-width: 34px;
  padding: 0;
  place-items: center;
  color: var(--muted);
  border-color: var(--line);
  background: #fff;
}

.known-device__remove:hover:not(:disabled) {
  color: var(--red);
  border-color: #e5aaa5;
  background: #fff0ed;
}

.device-history-empty {
  grid-column: 1 / -1;
  padding: 14px;
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  border-radius: 6px;
  font-size: 0.7rem;
  text-align: center;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.metric-card {
  --accent: var(--teal);
  display: grid;
  min-width: 0;
  min-height: 185px;
  grid-template-rows: auto 1fr auto;
  padding: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-small);
  animation: reveal 480ms ease both;
}

.metric-card:nth-child(1) { animation-delay: 130ms; }
.metric-card:nth-child(2) { animation-delay: 170ms; }
.metric-card:nth-child(3) { animation-delay: 210ms; }
.metric-card:nth-child(4) { animation-delay: 250ms; }

.metric-card--temperature { --accent: var(--coral); }
.metric-card--humidity { --accent: var(--cyan); }
.metric-card--battery { --accent: var(--green); }
.metric-card--time { --accent: var(--amber); }

.metric-card > header,
.metric-card > footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.metric-icon {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 11%, white);
  border-radius: 50%;
}

.metric-icon svg {
  width: 1rem;
  height: 1rem;
}

.metric-time,
.metric-card > footer {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.59rem;
}

.metric-card > div {
  align-self: center;
  padding-block: 16px 12px;
}

.metric-card > div p {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
}

.metric-card > div strong {
  display: block;
  min-height: 44px;
  font-family: var(--font-mono);
  font-size: 1.85rem;
  line-height: 1.3;
  white-space: nowrap;
}

.metric-card .icon-button {
  width: 32px;
  height: 32px;
  flex-basis: 32px;
}

.metric-progress {
  display: grid !important;
  grid-template-columns: auto minmax(50px, 82px);
  gap: 9px;
}

.progress-track {
  display: block;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: #e3e8e5;
}

.progress-track > span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
  transition: width 360ms ease, background-color 160ms ease;
}

.workbench {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}

.tool-panel {
  min-width: 0;
  padding: 22px;
}

.tool-panel__header {
  gap: 12px;
  justify-content: flex-start;
  margin-bottom: 22px;
}

.tool-panel__header--split {
  justify-content: space-between;
}

.tool-title {
  display: flex;
  gap: 12px;
  align-items: center;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 17px 14px;
}

.field,
.field-group {
  display: grid;
  gap: 7px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.field--wide {
  grid-column: 1 / -1;
}

.field > span,
.field-group legend,
.history-toolbar > label {
  color: var(--ink-soft);
  font-size: 0.7rem;
  font-weight: 800;
}

.field > span {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.field output {
  color: var(--teal-dark);
  font-family: var(--font-mono);
  font-size: 0.64rem;
}

select,
input[type="number"],
input[type="text"] {
  min-height: 42px;
  padding: 9px 11px;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: #fff;
  font-size: 0.76rem;
}

select:focus,
input:focus {
  border-color: var(--teal);
}

.segmented-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
}

.segmented-control label {
  min-width: 0;
}

.segmented-control input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.segmented-control span {
  display: grid;
  min-height: 36px;
  place-items: center;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: 4px;
  font-size: 0.73rem;
  font-weight: 800;
}

.segmented-control input:checked + span {
  color: var(--deep);
  border-color: var(--line);
  background: #fff;
  box-shadow: 0 1px 4px rgba(20, 42, 48, 0.08);
}

.segmented-control input:focus-visible + span {
  outline: 3px solid rgba(19, 169, 196, 0.38);
  outline-offset: 1px;
}

.segmented-control--temperature input[value="F"]:checked + span {
  color: #a54438;
}

.range-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 70px;
  gap: 12px;
  align-items: center;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--teal);
}

.range-field input[type="number"] {
  width: 70px;
  text-align: center;
}

.tool-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 22px;
}

.auto-clock-control {
  width: 100%;
  margin-top: 18px;
  padding: 11px 12px;
  border: 1px solid #cfe0dc;
  border-radius: 6px;
  background: #edf7f4;
}

.field-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.64rem;
}

.count-badge {
  padding: 5px 8px;
  color: var(--teal-dark);
  border-radius: 999px;
  background: #e4f4f1;
  font-family: var(--font-mono);
  font-size: 0.61rem;
  font-weight: 700;
}

.history-toolbar {
  display: grid;
  grid-template-columns: auto minmax(100px, 1fr) auto auto;
  gap: 8px;
  align-items: center;
}

.history-toolbar .button {
  min-height: 42px;
}

.history-status {
  min-height: 20px;
  margin: 13px 0 8px;
  color: var(--muted);
  font-size: 0.68rem;
}

.history-empty {
  display: grid;
  min-height: 150px;
  place-items: center;
  align-content: center;
  color: #879491;
  border: 1px dashed var(--line-strong);
  border-radius: 6px;
  background: #fafbf9;
}

.history-empty svg {
  width: 1.5rem;
  height: 1.5rem;
  margin-bottom: 6px;
}

.history-empty p {
  margin: 0;
  font-size: 0.7rem;
}

.history-table-wrap {
  height: 166px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.history-table-wrap table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  white-space: nowrap;
}

.history-table-wrap th,
.history-table-wrap td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid #e7ebe8;
}

.history-table-wrap th {
  position: sticky;
  z-index: 2;
  top: 0;
  color: var(--ink-soft);
  background: #f1f5f2;
  font-family: var(--font-sans);
  font-size: 0.61rem;
}

.history-table-wrap tbody tr:last-child td {
  border-bottom: 0;
}

.ha-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  gap: 20px 28px;
  margin-bottom: 22px;
  padding: 28px;
  color: #fff;
  border-color: var(--deep-2);
  background: linear-gradient(135deg, var(--deep-2), var(--deep));
  box-shadow: var(--shadow);
  scroll-margin-top: 88px;
  animation: reveal 480ms 40ms ease both;
}

.ha-panel h2 {
  margin-top: 8px;
  font-size: 1.5rem;
}

.ha-panel .section-kicker {
  display: inline-block;
  margin: 0;
  padding: 3px 10px;
  color: var(--deep-2);
  background: #6edce0;
  border-radius: 999px;
}

.ha-panel .tool-panel__icon {
  width: 46px;
  height: 46px;
  flex-basis: 46px;
  color: var(--deep-2);
  background: #6edce0;
}

.ha-panel__intro {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.ha-panel__intro p:last-child {
  margin: 10px 0 0;
  color: #c8d7d7;
  font-size: 0.88rem;
}

.ha-steps,
.ha-points {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ha-steps li {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 58px;
  padding: 9px 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
}

.ha-steps li > span {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  color: var(--deep-2);
  background: #6edce0;
  border-radius: 50%;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
}

.ha-steps p {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 700;
}

.ha-steps .button {
  min-height: 38px;
  padding: 8px 14px;
  font-size: 0.74rem;
  white-space: nowrap;
}

.ha-steps .button--primary {
  color: var(--deep-2);
  background: #6edce0;
  box-shadow: none;
}

.ha-steps .button--primary:hover:not(:disabled) {
  background: #a5eef0;
}

.ha-steps .button--secondary {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.4);
  background: transparent;
}

.ha-steps .button--secondary:hover:not(:disabled) {
  border-color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.ha-points {
  grid-column: 1 / -1;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.ha-points li {
  display: flex;
  gap: 9px;
  align-items: center;
  padding: 11px 12px;
  color: #e3f1f1;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 0.74rem;
  font-weight: 700;
}

.ha-points svg {
  flex: 0 0 auto;
  color: #6edce0;
}

.ha-note {
  display: flex;
  grid-column: 1 / -1;
  gap: 8px;
  align-items: flex-start;
  margin: 0;
  color: #c8d7d7;
  font-size: 0.72rem;
}

.ha-note svg {
  width: 0.95rem;
  height: 0.95rem;
  margin-top: 1px;
}

.ha-note a {
  color: #6edce0;
  font-weight: 800;
}

.logs-panel {
  margin-top: 16px;
  margin-bottom: 48px;
  padding: 20px 22px 22px;
}

.logs-panel > header {
  margin-bottom: 13px;
}

.logs {
  height: 200px;
  padding: 0 14px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f7f9f7;
  font-family: var(--font-mono);
  font-size: 0.64rem;
}

.logs-empty {
  display: grid;
  height: 100%;
  place-items: center;
  align-content: center;
  color: #8a9693;
}

.logs-empty svg {
  width: 1.55rem;
  height: 1.55rem;
}

.logs-empty p {
  margin: 7px 0 0;
}

.log-entry {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: baseline;
  padding: 10px 0;
  border-bottom: 1px solid #e0e5e2;
}

.log-entry:last-child {
  border-bottom: 0;
}

.log-entry__dot {
  width: 7px;
  height: 7px;
  background: var(--cyan);
  border-radius: 50%;
}

.log-entry[data-type="success"] .log-entry__dot { background: var(--green); }
.log-entry[data-type="warning"] .log-entry__dot { background: var(--amber); }
.log-entry[data-type="error"] .log-entry__dot { background: var(--red); }

.log-entry__message {
  overflow-wrap: anywhere;
}

.log-entry time {
  color: var(--muted);
  font-size: 0.57rem;
}

.site-footer {
  padding: 28px 0;
  color: #a9bcba;
  background: var(--deep-2);
}

.site-footer .container {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 30px;
  align-items: center;
}

.brand--footer {
  color: #fff;
}

.brand--footer img {
  width: 36px;
  height: 36px;
}

.brand--footer small {
  color: #93aaa8;
}

.site-footer p {
  margin: 0;
  font-size: 0.67rem;
}

.site-footer .container > p:last-child {
  text-align: right;
}

.site-footer a {
  color: #fff;
}

html[lang="ar"] body,
.language-links [lang="ar"] {
  font-family: "Noto Sans Arabic", sans-serif;
}

html[lang="zh-CN"] body,
.language-links [lang="zh-CN"] {
  font-family: "Noto Sans SC", sans-serif;
}

html[lang="hi"] body,
.language-links [lang="hi"] {
  font-family: "Noto Sans Devanagari", sans-serif;
}

html[dir="rtl"] .address-copy code,
html[dir="rtl"] .device-identity > div span,
html[dir="rtl"] .known-device__id,
html[dir="rtl"] .metric-card > div strong,
html[dir="rtl"] .metric-time,
html[dir="rtl"] .history-table-wrap {
  direction: ltr;
}

html[dir="rtl"] .site-footer .container > p:last-child {
  text-align: left;
}

.rename-dialog {
  width: min(460px, calc(100% - 32px));
  padding: 0;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 24px 80px rgba(10, 45, 51, 0.3);
}

.rename-dialog::backdrop {
  background: rgba(8, 29, 33, 0.66);
  backdrop-filter: blur(3px);
}

.rename-dialog form {
  padding: 22px;
}

.rename-dialog header {
  gap: 20px;
}

.rename-dialog form > p {
  margin: 18px 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.rename-dialog footer {
  gap: 9px;
  justify-content: flex-end;
  margin-top: 22px;
}

.noscript-message {
  position: fixed;
  z-index: 100;
  right: 20px;
  bottom: 20px;
  left: 20px;
  padding: 14px;
  color: #fff;
  border-radius: var(--radius);
  background: var(--red);
  text-align: center;
}

@keyframes reveal {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 1050px) {
  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .workbench {
    grid-template-columns: 1fr;
  }

  .ha-panel {
    grid-template-columns: 1fr;
  }

  .ha-points {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .known-devices ul {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .container {
    width: min(100% - 28px, 640px);
  }

  .github-link span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .intro {
    grid-template-columns: 1fr;
    gap: 24px;
    padding-top: 36px;
  }

  .intro h1 {
    font-size: 2rem;
  }

  .intro__visual {
    grid-row: 1;
    justify-self: start;
  }

  .intro__device {
    width: min(100%, 280px);
    height: auto;
  }

  .device-row,
  .connection-panel__footer {
    align-items: stretch;
    flex-direction: column;
  }

  .device-identity {
    flex-wrap: wrap;
  }

  .device-identity > div {
    flex: 1;
  }

  .connect-button {
    width: 100%;
  }

  .metrics {
    grid-template-columns: 1fr;
  }

  .metric-card {
    min-height: 170px;
  }

  .known-devices ul,
  .form-grid,
  .tool-actions {
    grid-template-columns: 1fr;
  }

  .field--wide {
    grid-column: auto;
  }

  .history-toolbar {
    grid-template-columns: 1fr auto auto;
  }

  .history-toolbar > label {
    grid-column: 1 / -1;
  }

  .ha-steps li {
    grid-template-columns: 28px minmax(0, 1fr);
  }

  .ha-steps .button {
    grid-column: 2;
    justify-self: start;
  }

  .ha-points {
    grid-template-columns: 1fr;
  }

  .site-footer .container {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .site-footer .container > p:last-child {
    text-align: left;
  }
}

@media (max-width: 390px) {
  .phone-gate h1 {
    font-size: 2rem;
  }

  .address-copy code {
    font-size: 0.63rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
