:root {
  color-scheme: light;
  --background: #fff;
  --panel: #fff;
  --text: #202124;
  --muted: #55585c;
  --line: #d3d3cf;
  --accent: #242526;
  --sidebar: #f2f2ef;
  --selected: #e2e3df;
  --error: #992e28;
  font: 1rem/1.5 system-ui, sans-serif;
  color: var(--text);
  background: var(--background);
}

* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }

.wrap {
  max-width: 48rem;
  margin: 0 auto;
  padding-inline: 1.25rem;
}

main {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-block: clamp(2rem, 8vw, 4rem);
  text-align: center;
}

.logo {
  width: 24rem;
  max-width: 100%;
  height: auto;
  margin-bottom: 1.5rem;
}

.mono, code { font-family: ui-monospace, monospace; }
.auth { width: 100%; max-width: 25rem; }
h1 { margin: 0 0 1rem; font-size: 1.375rem; line-height: 1.2; font-weight: 600; }
p { margin: .6rem 0 1rem; color: var(--muted); }

form {
  display: grid;
  justify-items: center;
  gap: .85rem;
  margin-bottom: 1rem;
}

label { display: block; font-size: .9rem; font-weight: 600; }
form label { width: 100%; }
.auth form { max-width: 19rem; margin-inline: auto; }
.auth form > button { width: 100%; font-weight: 600; }
.auth label { font-size: .8125rem; }
.auth input { border-color: #989a96; }

input, button {
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 2px;
  min-height: 2.5rem;
}

input {
  width: 100%;
  min-width: 0;
  padding: .4rem .6rem;
  text-align: center;
  color: var(--text);
  background: var(--panel);
}

label input { display: block; margin-top: .25rem; font-weight: 400; }
button { padding: .4rem .8rem; background: var(--accent); color: white; border-color: var(--accent); cursor: pointer; }
button:disabled { opacity: .65; cursor: wait; }
button:hover:enabled { filter: brightness(.92); }
.link { background: none; color: var(--accent); padding: 0; border: 0; text-decoration: underline; text-underline-offset: .2em; }
.login-links {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: .25em;
  font-size: clamp(.75rem, 3.6vw, 1rem);
  white-space: nowrap;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

main.signed-in {
  max-width: none;
  padding: 0;
  text-align: left;
}

#dashboard {
  display: grid;
  grid-template-columns: clamp(15rem, 23vw, 19rem) minmax(0, 1fr);
  width: 100%;
  min-height: 100vh;
}

.device-sidebar {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  padding: 1rem;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
}

.sidebar-heading { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.sidebar-heading h1 { margin: 0; font-size: 1rem; }
#add-device, #rename-device { font-size: .8125rem; }
#device-list { display: grid; gap: .25rem; }

.device-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  border: 1px solid transparent;
  border-radius: 2px;
}

.device-row:has(.select-device[aria-pressed="true"]) {
  background: var(--selected);
  border-color: #b6b8b3;
}

.device-row:has(.select-device:is(:hover, :focus-visible)) {
  background: var(--selected);
  border-color: var(--muted);
}

.device-row button {
  overflow-wrap: anywhere;
  background: none;
  color: var(--text);
  border: 0;
  text-align: left;
  font-size: .875rem;
}

.device-row .delete-device { color: var(--error); display: grid; place-items: center; padding-inline: .5rem; }
.device-row .delete-device:is(:hover, :focus-visible) { background: #f7e6e4; }
.delete-device svg { opacity: 0; }
:where(.device-row:hover, .device-row:has(:focus-visible)) .delete-device svg { opacity: .5; }
@media (hover: none) and (pointer: coarse) {
  .delete-device svg { opacity: .5; }
}
.delete-device:is(:hover, :focus-visible) svg { opacity: 1; }
.device-title { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }

#device-tabs { display: flex; gap: .75rem; margin-top: .75rem; border-bottom: 1px solid var(--line); }
#device-tabs button {
  padding-inline: .9rem;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
}
#device-tabs [aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

#account {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0 .75rem;
  margin-top: auto;
  border-top: 1px solid var(--line);
  padding-top: .5rem;
  font-size: .875rem;
  overflow-wrap: anywhere;
}

#device-pane { min-width: 0; padding: clamp(1rem, 4vw, 3rem); overflow-wrap: anywhere; }
#device-info { max-width: 48rem; }
#device-host { margin: 0; font-size: clamp(1.25rem, 2.5vw, 1.75rem); line-height: 1.25; }

.settings-panel > * + * { border-top: 1px solid var(--line); }
.settings-section, .settings-overview { padding-block: 1.25rem; }
.settings-overview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr));
  gap: 1.25rem 2rem;
}
.settings-overview .settings-section { padding: 0; }
.settings-section h3 { margin: 0; font-size: 1rem; }
.settings-section p { margin: .25rem 0 0; font-size: .875rem; }
.settings-section > :is(p, ul):empty { display: none; }
.settings-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem 1rem; }
.settings-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.5rem;
  max-width: 100%;
  padding: .4rem .75rem;
  border: 1px solid #a6a8a4;
  border-radius: 2px;
  color: var(--text);
  background: var(--panel);
  font-size: .875rem;
  text-decoration: none;
}
.settings-action:hover:where(:enabled, a) { background: var(--sidebar); filter: none; }

.settings-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: end;
  justify-items: stretch;
  gap: .75rem 1rem;
  margin: 1rem 0 0;
}
.settings-form .settings-full, .settings-form > .settings-action { grid-column: 1 / -1; }
.settings-form > .settings-action { justify-self: end; }
.settings-inline { grid-template-columns: minmax(0, 1fr) auto; }
.settings-inline > .settings-action { grid-column: auto; }
.settings-inline input { min-height: 2.5rem; }
.settings-form input { text-align: left; }
.settings-form input[type="file"]::file-selector-button {
  margin-right: .55rem;
  padding: .25rem .5rem;
  border: 1px solid var(--line);
  border-radius: .25rem;
  background: var(--sidebar);
  color: var(--text);
  cursor: pointer;
}
.settings-form select {
  width: 100%;
  min-height: 2.5rem;
  margin-top: .25rem;
  padding: .4rem .6rem;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-weight: 400;
}
.settings-form .settings-checkbox { display: flex; align-items: center; gap: .55rem; }
.settings-checkbox input { width: auto; min-height: 0; margin: 0; }

.diagnostic-terminal {
  margin: 1rem 0 0;
  border-radius: 2px;
  background: #222;
  color: #eee;
  font: .825rem/1.5 ui-monospace, monospace;
}
#diagnostic-output {
  min-height: 8rem;
  max-height: 20rem;
  margin: 0;
  padding: .9rem;
  overflow: auto;
  font: inherit;
  white-space: pre-wrap;
}
.diagnostic-prompt {
  display: flex;
  align-items: center;
  gap: 1ch;
  margin: 0;
  padding: .25rem .9rem;
  border-top: 1px solid #484848;
}
.diagnostic-prompt input {
  padding-inline: 0;
  border: 0;
  color: inherit;
  background: transparent;
  text-align: left;
}
.diagnostic-terminal :is(input, pre):focus { outline: none; }
.diagnostic-terminal ::selection { color: inherit; background: #484848; }
.diagnostic-prompt:focus-within { border-top-color: #999; }
#diagnostic-output:focus-visible { background: #292929; }

.settings-section dl {
  display: grid;
  grid-template-columns: minmax(6.5rem, 38%) minmax(0, 1fr);
  margin: .6rem 0 0;
  font-size: .875rem;
}
.settings-section dt { color: var(--muted); }
.settings-section dt, .settings-section dd { padding-block: .2rem; }
.settings-section dd { margin: 0; font-family: ui-monospace, monospace; font-variant-numeric: tabular-nums; }
#device-status[data-online="true"] { color: #27613d; }

@media (max-width: 38rem) {
  #dashboard { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .device-sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .settings-form { grid-template-columns: minmax(0, 1fr); }
}

#message { margin-top: 1.2rem; color: var(--accent); }
#message.error { color: var(--error); }
