:root {
  --bg: #efece6;
  --surface: #f7f6f3;
  --ink: #1c1a17;
  --muted: #6f6a62;
  --line: #ddd8d0;
  --line-strong: #1c1a17;
  --accent: #24302b;
  --on-accent: #f6f4ef;
  --danger: #8c3a32;
  --focus: #24302b;
  --sans: "IBM Plex Sans", "Segoe UI", sans-serif;
  --serif: "IBM Plex Serif", "Times New Roman", serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; min-height: 100%; }

body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
}

button, input { font: inherit; color: inherit; }

.shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
}

.panel {
  width: min(100%, 420px);
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 32px 28px 28px;
}

.panel-wide { width: min(100%, 640px); }

.done { width: min(100%, 320px); }

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  font-size: 15px;
}

.brand-name, .brand-note, .choice-meta { margin: 0; }

.brand-name {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.brand-note, .choice-meta { color: var(--muted); font-size: 13px; }

h1 {
  margin: 0 0 8px;
  font-family: var(--serif);
  font-size: 32px;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.lede { margin: 0 0 24px; color: var(--muted); }

.field { margin-bottom: 16px; }

.label-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

label, .choice-title {
  display: block;
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 500;
}

input[type="text"], input[type="password"], .file-name {
  width: 100%;
  height: 48px;
  padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 0;
}

input:focus-visible, button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.primary, .ghost, .text-btn, .choice { cursor: pointer; }

.primary, .ghost {
  height: 48px;
  border: 1px solid transparent;
  transition: background-color 180ms ease, border-color 180ms ease;
}

.primary {
  width: 100%;
  margin-top: 8px;
  background: var(--accent);
  color: var(--on-accent);
}

.primary:hover:not(:disabled) { background: #1b2622; }

.primary:disabled { cursor: not-allowed; opacity: 0.4; }

.ghost {
  flex: 0 0 auto;
  padding: 0 16px;
  background: transparent;
  border-color: var(--line-strong);
}

.ghost:hover { background: #efece6; }

.text-btn {
  padding: 8px 0;
  min-height: 44px;
  background: none;
  border: 0;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.text-btn:hover { color: var(--ink); }

.form-error { margin: 0 0 12px; color: var(--danger); font-size: 14px; }

.work-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.work-bar .brand { margin-bottom: 0; }

.bar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 12px;
  flex-shrink: 0;
}

.work-bar .ghost {
  height: 44px;
  padding: 0 14px;
}

.admin-nav {
  display: grid;
  gap: 12px;
}

.admin-nav .choice {
  min-height: 56px;
  width: 100%;
  display: flex;
  align-items: center;
}

.admin-nav .choice-title { margin-bottom: 0; }

.section-body {
  min-height: 120px;
  padding: 8px 16px;
  border: 1px solid var(--line);
}

.section-body--phone {
  min-height: 0;
  padding: 8px 0 4px;
  border: 0;
  display: grid;
  place-items: center;
}

.section-body--settings {
  min-height: 0;
  padding: 0;
  border: 0;
}

.section-body--vitrine {
  padding: 4px 0 0;
}

.queue {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: min(52vh, 440px);
  overflow: auto;
}

.queue li {
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.queue li:last-child { border-bottom: 0; }

.queue-file {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 500;
}

.queue-meta {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.device-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.device-card {
  padding: 16px;
  border: 1px solid var(--line);
}

.device-name {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 500;
}

.device-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 14px;
}

.device-status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #8a8680;
}

.device-meta {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.settings {
  display: grid;
  gap: 12px;
}

.settings > .choice {
  min-height: 56px;
  width: 100%;
  display: flex;
  align-items: center;
}

.settings .choice-title { margin-bottom: 0; }

.settings-panel {
  padding: 16px;
  border: 1px solid var(--line);
}

.settings-panel .lede { margin-bottom: 16px; }

.settings-panel .primary { margin-top: 0; }

.filter-list {
  display: grid;
  gap: 4px;
  margin: 0 0 16px;
  padding: 0;
  border: 0;
}

.filter-list legend {
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 500;
}

.filter-list label {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  margin: 0;
  font-weight: 400;
  cursor: pointer;
}

.filter-list input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}

.scan-note, .check-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 15px;
}

.username-row {
  display: flex;
  gap: 8px;
}

.username-row .primary {
  width: auto;
  flex: 0 0 auto;
  padding: 0 16px;
  margin-top: 0;
}

.helper {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.lede[hidden] { display: none !important; }

.empty {
  margin: 0;
  padding: 12px 0;
  color: var(--muted);
  font-size: 15px;
}

.journal {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: min(52vh, 440px);
  overflow: auto;
}

.journal li {
  display: grid;
  grid-template-columns: 6.4em 1fr;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.journal li:last-child { border-bottom: 0; }

.journal time {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.phone {
  width: min(100%, 268px);
}

.phone-bezel {
  position: relative;
  padding: 12px 11px 16px;
  border-radius: 36px;
  background: #161513;
  border: 1px solid #2f2c28;
  box-shadow: 0 18px 40px rgba(28, 26, 23, 0.16);
}

.phone-bezel::before,
.phone-bezel::after {
  content: "";
  position: absolute;
  right: -2px;
  width: 3px;
  border-radius: 2px 0 0 2px;
  background: #2a2724;
}

.phone-bezel::before { top: 96px; height: 28px; }
.phone-bezel::after { top: 136px; height: 52px; }

.phone-ear {
  position: absolute;
  top: 8px;
  left: 50%;
  width: 72px;
  height: 8px;
  border-radius: 8px;
  background: #0b0b0a;
  transform: translateX(-50%);
}

.phone-screen {
  height: 468px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  border-radius: 26px;
  background: #0e0f0d;
  color: #d8d4cc;
  overflow: hidden;
}

.phone-status {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px 8px;
  font-size: 12px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.phone-bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 10px;
}

.phone-bars i {
  display: block;
  width: 3px;
  border: 1px solid #6f6a62;
  border-radius: 1px;
}

.phone-bars i:nth-child(1) { height: 4px; }
.phone-bars i:nth-child(2) { height: 6px; }
.phone-bars i:nth-child(3) { height: 8px; }
.phone-bars i:nth-child(4) { height: 10px; }

.phone-bars.is-on i {
  background: #d8d4cc;
  border-color: #d8d4cc;
}

.phone-feed {
  overflow: auto;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 8px;
  padding: 8px 14px 12px;
}

.phone-bubble {
  margin: 0;
  padding: 10px 12px;
  border-radius: 14px;
  background: #1c1e1a;
  font-size: 14px;
  line-height: 1.4;
  color: #d8d4cc;
  white-space: pre-wrap;
  word-break: break-word;
}

.phone-message {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 16px;
  padding: 24px 28px;
  text-align: center;
}

.phone-message svg {
  width: 40px;
  height: 40px;
  color: #9a958c;
}

.phone-message p {
  margin: 0;
  font-size: 15px;
  line-height: 1.4;
  color: #d8d4cc;
}

.phone-home {
  justify-self: center;
  width: 96px;
  height: 4px;
  margin-bottom: 10px;
  border-radius: 4px;
  background: #3a3732;
}

.choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.choice {
  min-height: 88px;
  padding: 14px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  transition: border-color 180ms ease, background-color 180ms ease;
}

.choice:hover { border-color: #b7b1a7; }

.choice[aria-pressed="true"] {
  border-color: var(--line-strong);
  background: #f3f1ec;
}

.choice-title { margin-bottom: 2px; }

.file-block { margin-bottom: 8px; }

.file-row { display: flex; gap: 8px; }

.file-name { color: var(--muted); }

.file-name.has-file { color: var(--ink); }

.wait {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: turn 900ms linear infinite;
}

@keyframes turn { to { transform: rotate(360deg); } }

@media (max-width: 640px) {
  .panel { padding: 24px 18px 20px; }
  h1 { font-size: 28px; }
  .choices { grid-template-columns: 1fr; }
  .device-grid { grid-template-columns: 1fr; }
  .file-row { flex-direction: column; }
  .username-row { flex-direction: column; }
  .username-row .primary { width: 100%; }
  .ghost { width: 100%; }
  .work-bar .ghost { width: auto; }
  .phone-screen { height: 400px; }
}

@media (max-height: 760px) {
  .phone-screen { height: 360px; }
  .journal { max-height: 40vh; }
}

@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; border-top-color: var(--ink); }
  *, *::before, *::after { transition: none !important; }
}
