:root {
  font-family: "Segoe UI", system-ui, sans-serif;
  color: #182a25;
  background: #edf2ee;
  font-synthesis: none;
  --ink: #182a25;
  --muted: #53665e;
  --paper: #fdfefa;
  --line: #d9dfd5;
  --pine: #132d25;
  --green: #205f46;
  --light-green: #e5efe2;
  --red: #902d34;
  accent-color: var(--green);
  scrollbar-color: #a0b6a8 transparent;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
::selection { background: #d5e9d3; color: var(--pine); }
:focus-visible { outline: 2px solid #448265; outline-offset: 3px; }
body { margin: 0; }
button, input, textarea, select { font: inherit; }
button {
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: .64rem .88rem;
  min-height: 42px;
  background: transparent;
  color: inherit;
  text-align: center;
  font-weight: 600;
}
.primary { background: var(--green); color: white; }
.primary:hover { background: #184d39; }
.secondary { background: var(--paper); border-color: #cbd7cc; color: var(--ink); }
.secondary:hover, .plain:hover { background: var(--light-green); }
.plain { color: var(--green); }
.destructive { color: var(--red); }
.destructive:hover { background: #f5e6e6; }
.danger { background: var(--red); color: white; }
.danger:hover { background: #75242a; }
.actions { display: flex; align-items: center; flex-wrap: wrap; gap: .55rem; }
h1, h2, p { margin: 0; }
h1, h2 { line-height: 1.13; letter-spacing: -.026em; }
h1 { font-size: clamp(1.65rem, 2.7vw, 2.25rem); }
h2 { font-size: clamp(1.32rem, 2.4vw, 1.86rem); }
p { line-height: 1.55; }

.frame { min-height: 100vh; display: grid; grid-template-columns: 15rem minmax(0, 1fr); }
.sidebar {
  background: var(--pine);
  color: #f3faf4;
  padding: 1.75rem 1.25rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 2.65rem;
}
.brand { display: flex; align-items: center; gap: .65rem; font-weight: 700; font-size: 1.28rem; letter-spacing: -.035em; }
.mark { border-radius: 6px; }
.sidebar nav { display: grid; gap: .4rem; }
.sidebar button { text-align: left; width: 100%; color: #dfefe3; }
.sidebar button:hover, .sidebar button[aria-pressed="true"] { background: #2a4a3c; color: #f9fff8; }
.sidebar :focus-visible { outline-color: #b4dfc1; }
.side-end { margin-top: auto; display: grid; gap: .65rem; }
.side-note { display: flex; align-items: center; gap: .45rem; padding: .8rem .3rem 0; color: #c4d9ca; border-top: 1px solid #486053; font-size: .81rem; }
.side-note span { width: 7px; height: 7px; border-radius: 50%; background: #bad89d; }

.gate { min-height: 100vh; display: grid; place-items: center; padding: 2rem; }
.gate-inner { width: min(100%, 38rem); background: var(--paper); border: 1px solid var(--line); padding: clamp(1.5rem, 5vw, 3.5rem); border-radius: 15px; }
.gate h1 { font-size: clamp(2rem, 4.2vw, 3.35rem); max-width: 14ch; }
.gate-inner > p { color: var(--muted); margin: .9rem 0 1.2rem; }
.gate-inner .demo-hint { font-size: .87rem; overflow-wrap: anywhere; margin-bottom: 0; }
.gate-inner .error { margin-bottom: 0; color: var(--red); }

.workspace { max-width: 82rem; margin: 0 auto; padding: 2rem clamp(1rem, 3.1vw, 3rem); }
.toolbar { display: flex; justify-content: space-between; gap: 1rem; align-items: center; margin-bottom: 1.45rem; }
.columns { display: grid; grid-template-columns: minmax(13rem, .73fr) minmax(0, 1.27fr); gap: 1rem; align-items: start; }
.catalog, .detail { min-width: 0; border: 1px solid var(--line); border-radius: 13px; background: var(--paper); padding: 1.12rem; }
.count { color: var(--muted); font-size: .82rem; margin: .85rem .2rem .45rem; font-variant-numeric: tabular-nums; }
.items { margin: 0; padding: 0; list-style: none; max-height: 60vh; overflow: auto; }
.items li + li { margin-top: .2rem; }
.items button { padding: .64rem; width: 100%; display: flex; align-items: center; gap: .7rem; text-align: left; }
.items button:hover, .items button[aria-current="true"] { background: var(--light-green); }
.items button:focus-visible { outline-offset: -2px; }
.item-text { display: grid; gap: .14rem; min-width: 0; }
.item-text > * { text-overflow: ellipsis; overflow: hidden; white-space: nowrap; }
.item-text small, .detail-end small { color: var(--muted); font-weight: 400; }
.item-symbol { width: 2.1rem; height: 2.1rem; flex: none; display: grid; place-items: center; color: #286046; border: 1px solid #bcd6c1; background: #f1f7ed; border-radius: 8px; }
.item-symbol::after { content: ""; display: block; width: .75rem; height: .52rem; border: 1.5px solid currentColor; border-radius: 2px; box-shadow: 0 -4px 0 -1px currentColor; }
.item-symbol.note { color: #79591b; background: #fbf3dd; border-color: #e3d1a8; }
.item-symbol.note::after { width: .62rem; height: .78rem; box-shadow: none; background: linear-gradient(currentColor,currentColor) center / 55% 1px no-repeat; }
.item-symbol.wifi::after { width: .78rem; height: .78rem; border-width: 2px 0 0 2px; border-radius: 80% 0 0; box-shadow: none; transform: rotate(45deg); }
.item-symbol.large { width: 3.2rem; height: 3.2rem; }
.detail { padding: clamp(1.2rem, 3vw, 2.2rem); }
.detail-top { display: flex; align-items: center; gap: .85rem; }
.detail-top p { font-size: .82rem; color: var(--muted); margin-bottom: .25rem; }
.detail h2 { overflow-wrap: anywhere; }
.detail-actions { margin-top: 1.1rem; }
.detail dl { margin: 1.25rem 0 .9rem; border-top: 1px solid var(--line); }
.field { padding: .8rem 0; border-bottom: 1px solid var(--line); }
.field dt { color: var(--muted); font-size: .82rem; margin-bottom: .17rem; }
.field dd { margin: 0; display: flex; justify-content: space-between; flex-wrap: wrap; align-items: center; gap: .5rem; }
.field dd > span { min-width: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.field-actions { display: flex; flex-wrap: wrap; }
.secret, .recovery-code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
.detail-end { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem; }
.empty { padding: 1.5rem .3rem; }
.empty p { margin-top: .6rem; color: var(--muted); }
.status { margin: .7rem .25rem 0; color: var(--green); min-height: 1.5rem; }
#gate-info:empty { display: none; }

dialog { width: min(34rem, calc(100% - 1.5rem)); max-height: calc(100% - 1.5rem); border: 0; border-radius: 14px; background: var(--paper); color: var(--ink); padding: clamp(1rem, 4vw, 2rem); box-shadow: 0 16px 60px #132d254d; }
dialog::backdrop { background: #142d25a6; }
dialog h2 { margin-bottom: 1.1rem; }
dialog p { margin: .55rem 0 .9rem; color: var(--muted); }
form { display: grid; gap: .85rem; }
label, .form-field { display: grid; gap: .32rem; }
label { font-weight: 600; font-size: .89rem; }
input, textarea, select { width: 100%; border: 1px solid #b9c8bb; border-radius: 7px; background: var(--paper); color: var(--ink); caret-color: var(--green); padding: .64rem .7rem; font-weight: 400; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
textarea { resize: vertical; }
.family-exchange { display: grid; gap: .35rem; margin: .85rem 0; }
.family-copy { justify-self: start; }
.family-note { margin: .65rem 0 1rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.family-choices { min-inline-size: 0; margin: 0; padding: .4rem .65rem .65rem; border: 1px solid #b9c8bb; border-radius: 7px; }
.family-choices legend { padding: 0 .25rem; font-weight: 600; }
.family-choices-list { display: grid; max-height: 15rem; overflow-y: auto; }
.family-choice { display: flex; align-items: flex-start; gap: .7rem; padding: .45rem .2rem; overflow-wrap: anywhere; }
.family-choice input { flex: none; width: 1rem; height: 1rem; margin: .15rem 0 0; accent-color: var(--green); }
.family-choice small { display: block; color: var(--muted); font-weight: 400; }
dialog p.family-selection-help { margin: 0; }
.family-entries { list-style: none; padding: 0; margin: 0 0 1rem; overflow-wrap: anywhere; }
.family-entries li + li { border-top: 1px solid #b9c8bb; margin-top: .85rem; padding-top: .85rem; }
.family-entry-fields { margin: .55rem 0; }
.family-entry-fields dt { color: var(--muted); font-size: .85rem; }
.family-entry-fields dd { margin: 0 0 .4rem; }
.family-entry-secret summary { color: var(--green); cursor: pointer; margin-bottom: .35rem; }
.login-fields, .settings-list { display: grid; gap: .72rem; }
.history-title, .item-history { overflow-wrap: anywhere; }
.item-history { margin: 0 0 1rem; padding-inline-start: 1.5rem; }
.item-history li { padding: .65rem 0; border-top: 1px solid var(--line); }
.item-history small { color: var(--muted); }
.item-history form { justify-items: start; margin-top: .35rem; }
.wifi-fields { display: grid; gap: .72rem; border: 0; margin: 0; padding: 0; min-width: 0; }
.wifi-fields legend { margin-bottom: .45rem; font-weight: 600; }
.wifi-fields .wifi-hidden { display: flex; align-items: center; gap: .5rem; }
.wifi-hidden input { width: auto; }
.wifi-qr { margin: .75rem 0; }
.wifi-qr canvas { display: block; max-width: 100%; height: auto; image-rendering: pixelated; }
.sync-actions { margin-top: .8rem; }
.login-fields button, .settings-list button { justify-self: start; }
.recovery-code { display: block; padding: .8rem; border-radius: 7px; background: var(--light-green); overflow-wrap: anywhere; margin-bottom: 1rem; }
.error { color: var(--red); }
.error:empty { display: none; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

@media (max-width: 850px) {
  .frame { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .sidebar { padding: .85rem 1rem; gap: .7rem; }
  .sidebar nav { display: flex; flex-wrap: wrap; }
  .sidebar nav button, .sidebar .side-end button { width: auto; }
  .side-end { display: flex; flex-wrap: wrap; align-items: center; margin: 0; }
  .side-note { border: 0; padding: 0; }
  .gate { min-height: 0; padding: 1rem; }
}
@media (max-width: 580px) {
  .workspace { padding: 1.1rem .8rem; }
  .toolbar { flex-wrap: wrap; margin-bottom: .85rem; }
  .columns { grid-template-columns: minmax(0, 1fr); gap: .65rem; }
  .items { max-height: 13rem; }
  .sidebar nav button { padding: .42rem .55rem; }
}
