/*
 * byCart – Oberfläche.
 *
 * Mobil zuerst: die Liste wird im Laden mit einer Hand bedient, deshalb
 * großzügige Tippflächen und die Eingabe oben in Daumennähe.
 */

:root {
  --paper: #f5f6f2;
  --surface: #ffffff;
  --surface-2: #edefe9;
  --ink: #16201a;
  --muted: #5c6a61;
  --line: #d9ded6;
  --accent: #2e6b4c;
  --accent-soft: #e3ede6;
  --danger: #93302e;
  --radius: 6px;
  --tap: 44px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #101410;
    --surface: #191e19;
    --surface-2: #212721;
    --ink: #e7ebe4;
    --muted: #97a398;
    --line: #2b332b;
    --accent: #74c495;
    --accent-soft: #1d2c23;
    --danger: #d9736c;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.55 "Segoe UI Variable Text", "Segoe UI", -apple-system,
        BlinkMacSystemFont, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}

main { max-width: 44rem; margin: 0 auto; padding: 1rem 1rem 4rem; }
.narrow { max-width: 34rem; margin: 0 auto; }

/* ---------------------------------------------------------- Kopfzeile */

.topbar {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
  padding: .7rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: -.01em;
}

.space-name { color: var(--muted); font-size: .92rem; }

.topnav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: .9rem;
  font-size: .88rem;
}

.topnav a { color: var(--muted); text-decoration: none; }
.topnav a:hover, .topnav a:focus-visible { color: var(--accent); }

/* ----------------------------------------------------------- Eingabe */

.add-form {
  position: relative;
  display: flex;
  gap: .5rem;
  margin-bottom: 1.5rem;
}

.add-form input[type="text"] {
  flex: 1;
  min-width: 0;
  min-height: var(--tap);
  padding: .6rem .8rem;
  font-size: 1rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.add-form input[type="text"]:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 20;
  margin: 0;
  padding: 0;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 6px 20px rgb(0 0 0 / .12);
  max-height: 15rem;
  overflow-y: auto;
}

.suggestions li {
  display: flex;
  justify-content: space-between;
  gap: .75rem;
  padding: .6rem .8rem;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
}

.suggestions li:last-child { border-bottom: none; }
.suggestions li:hover { background: var(--accent-soft); }
.suggestion-cat { color: var(--muted); font-size: .82rem; }

/* ------------------------------------------------------------- Liste */

.list-section { margin-bottom: 2rem; }

.list-section h2 {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 .6rem;
}

.count {
  font-variant-numeric: tabular-nums;
  background: var(--surface-2);
  color: var(--muted);
  border-radius: 999px;
  padding: .05rem .45rem;
  font-size: .75rem;
  letter-spacing: 0;
}

.items { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }

.item {
  display: flex;
  align-items: center;
  gap: .75rem;
  min-height: var(--tap);
  padding: .5rem .8rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.item-body { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap; }
.item-name { font-weight: 500; }
.item-qty { color: var(--accent); font-size: .88rem; font-variant-numeric: tabular-nums; }
.item-note { color: var(--muted); font-size: .85rem; }

.item-cat {
  color: var(--muted);
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  white-space: nowrap;
}

.items.checked .item { opacity: .6; }
.items.checked .item-name { text-decoration: line-through; }

/* Große Tippfläche: das Abhaken passiert einhändig im Laden. */
.checkbox {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}

.checkbox:hover { border-color: var(--accent); }
.checkbox:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.checkbox.checked {
  background: var(--accent);
  border-color: var(--accent);
  position: relative;
}

.checkbox.checked::after {
  content: "";
  position: absolute;
  left: 8px;
  top: 4px;
  width: 5px;
  height: 10px;
  border: solid var(--surface);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.check-form { display: contents; }

/* ---------------------------------------------------------- Formulare */

.stacked { display: flex; flex-direction: column; gap: .4rem; margin-bottom: 1.5rem; }
.stacked label { font-size: .85rem; font-weight: 600; color: var(--muted); }

.stacked input[type="text"],
.stacked input[type="email"],
.stacked input[type="number"] {
  min-height: var(--tap);
  padding: .55rem .75rem;
  font-size: 1rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

button, .button {
  min-height: var(--tap);
  padding: .55rem 1.1rem;
  font: inherit;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: flex-start;
}

button:focus-visible, .button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button.secondary {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--line);
}

button.danger, button.secondary.danger { color: var(--danger); border-color: var(--danger); background: var(--surface); }

button.linklike {
  min-height: auto;
  padding: 0;
  background: none;
  border: none;
  color: var(--muted);
  font-weight: 400;
  font-size: .85rem;
  text-decoration: underline;
}

button.linklike.danger { color: var(--danger); }
.inline { display: inline; }

.scopes { border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem; margin: .3rem 0; }
.scopes legend { font-size: .85rem; font-weight: 600; color: var(--muted); padding: 0 .3rem; }
.checkbox-label { display: flex; align-items: center; gap: .5rem; min-height: 2rem; font-weight: 400; }

/* -------------------------------------------------------------- Text */

h1 { font-size: 1.5rem; line-height: 1.2; margin: 0 0 1rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 1.75rem 0 .6rem; }
p { margin: 0 0 1rem; }
a { color: var(--accent); }
code { font-family: Consolas, "Cascadia Mono", ui-monospace, monospace; font-size: .88em; }

.hint, .empty, .sync-note { color: var(--muted); font-size: .88rem; }
.empty { padding: 1.5rem 0; text-align: center; }
.sync-note { min-height: 1.4em; text-align: center; }
.optional { font-weight: 400; color: var(--muted); }

.note {
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: .75rem 1rem;
  margin-bottom: 1.25rem;
}

.note p:last-child { margin-bottom: 0; }
.note-warn { border-left-color: var(--danger); }

.token {
  display: block;
  overflow-wrap: anywhere;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .6rem .75rem;
  margin: .5rem 0;
  user-select: all;
}

.badge {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: 999px;
  padding: .1rem .5rem;
}

/* ------------------------------------------------------------- Listen */

.space-list, .device-list, .member-list, .token-list, .event-list {
  list-style: none;
  margin: 0 0 1.5rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.space-list li, .device-list li, .member-list li, .token-list li, .event-list li {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex-wrap: wrap;
  padding: .6rem .8rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.device-label, .token-name { font-weight: 500; }
.device-meta, .token-meta, .token-scopes { color: var(--muted); font-size: .82rem; }
.device-list li form, .token-list li form { margin-left: auto; }
.token-list li.revoked { opacity: .55; }

.event-list { font-size: .88rem; }
.event time { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.event-name { font-weight: 500; }
.event-type { color: var(--muted); }
.event-qty { color: var(--accent); font-variant-numeric: tabular-nums; margin-left: auto; }
.event-checked { border-left: 3px solid var(--accent); }
.event-removed { opacity: .6; }

.page-error main { text-align: center; padding-top: 4rem; }
.page-error h1 { font-size: 3rem; color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
