/* Reusable pieces: cards, buttons, inputs, empty states, modal, toast. */

.card { background: var(--surface); border-radius: var(--radius-lg); border: 1px solid var(--border); padding: 16px 18px; margin-bottom: 12px; }

.section-title { font-size: 11px; font-weight: 600; color: var(--text-faint); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 12px; }
.section-hint { color: var(--text-ghost); font-weight: 400; text-transform: none; letter-spacing: 0; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; font-size: 13px; font-weight: 500;
  border-radius: var(--radius-sm); border: 1px solid var(--border-input);
  background: var(--surface); color: var(--accent); cursor: pointer;
  transition: background .15s, border-color .15s;
  white-space: nowrap; font-family: inherit;
}
.btn:hover { background: var(--accent-soft); border-color: var(--border-btn-hover); }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { color: var(--danger); border-color: var(--danger-border); background: var(--surface); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon {
  width: 32px; height: 32px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); border: 1px solid var(--border-tab);
  background: var(--surface); color: var(--icon); cursor: pointer;
  font-size: 16px; transition: background .15s; font-family: inherit;
}
.btn-icon:hover { background: var(--surface-hover); }
.btn-icon:disabled { opacity: .35; cursor: default; pointer-events: none; }

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

/* A <button> that should look like inline text. */
.link-btn {
  background: none; border: none; padding: 0; font: inherit; color: inherit;
  text-align: left; cursor: pointer;
}

/* ── Inputs ── */
input[type="date"] {
  font-size: 13px; padding: 6px 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-input); background: var(--surface); color: var(--text);
  font-family: inherit; cursor: pointer;
}
.text-input, .modal input, .modal textarea {
  width: 100%; padding: 9px 12px; font-size: 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-input);
  background: var(--surface); color: var(--text); font-family: inherit; transition: border-color .15s;
}
.text-input:focus, .modal input:focus, .modal textarea:focus { outline: none; border-color: var(--accent); }
.text-input::placeholder { color: var(--text-ghost); }

/* ── Empty state ── */
.empty-state { text-align: center; padding: 36px 16px; color: var(--text-faint); font-size: 14px; }
.empty-icon { font-size: 36px; margin-bottom: 10px; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; background: var(--overlay); overscroll-behavior: contain;
  display: flex; align-items: center; justify-content: center; z-index: 200; padding: 16px;
}
.modal { background: var(--surface); border-radius: 14px; padding: 24px; width: 100%; max-width: 420px; box-shadow: var(--shadow-modal); max-height: 90vh; overflow-y: auto; overscroll-behavior: contain; }
/* While a dialog is open the page behind it doesn't scroll. */
body.modal-open { overflow: hidden; }
.modal h2 { font-size: 16px; font-weight: 600; margin-bottom: 16px; color: var(--text); }
.modal label { font-size: 13px; color: var(--text-muted); display: block; margin-bottom: 6px; margin-top: 14px; }
.modal label:first-of-type { margin-top: 0; }
.modal .label-hint { color: var(--text-ghost); font-weight: 400; }
.modal .modal-sub { font-size: 13px; color: var(--text-subtle); margin-bottom: 14px; }
.modal textarea { resize: vertical; font-size: 13px; line-height: 1.5; min-height: 80px; }
.modal textarea.mono { font-family: var(--font-mono); font-size: 12px; min-height: 120px; }
/* Wraps on narrow phones; a secondary group (Archive/Delete) then gets its own line. */
.modal-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; justify-content: flex-end; }
.modal-actions-secondary { display: flex; gap: 8px; margin-right: auto; }
.modal-actions-primary { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-left: auto; } /* Cancel + Save stay together */
.modal-error { color: var(--danger); font-size: 13px; margin-top: 10px; }

/* ── Toast ── */
.toast {
  position: fixed; left: 50%;
  bottom: calc(24px + var(--bottom-nav-h, 0px) + env(safe-area-inset-bottom)); /* above the phone tab bar */
  transform: translateX(-50%) translateY(16px);
  background: var(--toast-bg); color: var(--toast-text); font-size: 13px;
  padding: 10px 18px; border-radius: var(--radius-sm); z-index: 999;
  /* Hidden by opacity/visibility, not by sliding off-screen: off-screen depends on where the
     bottom is, and once it sat above the phone tab bar the "hidden" toast peeked out. */
  opacity: 0; visibility: hidden;
  transition: transform .25s ease, opacity .25s ease, visibility 0s linear .25s;
  pointer-events: none;
  max-width: calc(100vw - 32px); text-align: center;
  box-shadow: var(--shadow-modal);
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; visibility: visible; transition-delay: 0s; }
.toast.has-action { pointer-events: auto; display: flex; align-items: center; gap: 12px; }
.toast-action {
  background: none; border: none; padding: 2px 4px; font: inherit; font-weight: 600;
  color: var(--toast-action); cursor: pointer; border-radius: 4px;
}
.toast-action:hover { text-decoration: underline; }

/* ── Form controls inside modals ── */
.modal fieldset { border: none; margin-top: 16px; }
.modal legend { font-size: 13px; color: var(--text-muted); margin-bottom: 8px; }
.modal input[type="radio"], .modal input[type="checkbox"] { width: auto; }
.modal label.radio, .modal label.chip { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
.radio-row { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--text); }
.radio-row input { accent-color: var(--accent); }
.chip-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-block; padding: 5px 10px; font-size: 12px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border-input); color: var(--text-muted); background: var(--surface);
}
.chip input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.inline-fields { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 13px; color: var(--text-muted); }
.modal .inline-fields input[type="number"] { width: 80px; flex: none; }
.modal .inline-fields input[type="text"] { flex: 1; }
.field-hint { font-size: 12px; color: var(--text-faint); margin-top: 6px; }

/* Keyboard shortcut list (the ? sheet and Settings). */
.shortcuts { width: 100%; border-collapse: collapse; font-size: 13px; color: var(--text-muted); }
.shortcuts td { padding: 7px 0; border-top: 1px solid var(--border); vertical-align: middle; }
.shortcuts tr:first-child td { border-top: none; }
.shortcuts td:first-child { white-space: nowrap; padding-right: 16px; width: 1%; }

kbd {
  font-family: var(--font-mono); font-size: 11px; padding: 1px 6px; border-radius: 4px;
  border: 1px solid var(--border-input); background: var(--surface); color: var(--text-muted);
}
