/* Web portal (app.html) — layers on top of style.css, reusing its variables. */

:root { --wide: 1200px; }

/* The page shows/hides whole screens with the `hidden` attribute, and several of them
   also carry a `display: flex` rule — which would beat the UA stylesheet's
   `[hidden] { display: none }` and leave them visible. This has to win. */
[hidden] { display: none !important; }

.nav-right { display: flex; align-items: center; gap: 16px; }
.nav-right .who { color: var(--muted); font-size: 0.92rem; }
.nav-right a.link { white-space: nowrap; }

/* Buttons & form controls */
.btn {
  font: inherit; font-weight: 600; font-size: 0.94rem;
  padding: 9px 15px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: #cfc8b8; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.primary:hover { opacity: 0.92; }
.btn.danger { color: #c0392b; border-color: #e6bdb6; }
.btn.danger:hover { background: #fdf3f1; }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 11px; font-size: 0.88rem; }
.btn.block { width: 100%; padding: 12px; font-size: 1rem; }
.btn:disabled { opacity: 0.5; cursor: default; }

input, select, textarea {
  font: inherit; color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px;
  max-width: 100%;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible, .chip:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
textarea { resize: vertical; font-family: inherit; }
.muted { color: var(--muted); }
.fine { font-size: 0.86rem; }
.err { color: #c0392b; font-size: 0.92rem; margin: 10px 0 0; min-height: 1.2em; }
.err:empty { min-height: 0; margin: 0; }

/* ------------------------------- Auth screen ------------------------------- */
.auth-wrap { display: flex; justify-content: center; padding: 40px 20px 80px; }
.auth-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 32px; width: 100%; max-width: 420px;
}
.auth-card h1 { font-size: 1.5rem; margin: 0 0 8px; }
.auth-card form { display: flex; flex-direction: column; gap: 6px; margin-top: 22px; }
.auth-card label { font-weight: 600; font-size: 0.9rem; margin-top: 10px; }
.auth-card .btn { margin-top: 18px; }
.auth-card .switch { margin: 18px 0 0; }
.auth-card .fine { margin: 14px 0 0; }

/* -------------------------------- List screen ------------------------------ */
.app-wrap { max-width: var(--wide); margin: 0 auto; padding: 0 20px 60px; }

.list-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 12px 0 20px; }
.list-head h1 { font-size: 1.7rem; margin: 0; }
.list-head p { margin: 4px 0 0; font-size: 0.94rem; }
.sync { font-size: 0.88rem; color: var(--muted); min-height: 1.2em; }
.sync.saving { color: var(--accent); }
.sync.error { color: #c0392b; font-weight: 600; }

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
/* Keeps the four buttons together as one right-aligned group, so a narrow window wraps
   all of them to the next line instead of orphaning the last one. */
.toolbar .actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-left: auto; }
.search { min-width: 200px; flex: 0 1 260px; }

.chips { display: flex; gap: 6px; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.chip {
  font: inherit; font-size: 0.88rem; font-weight: 600; color: var(--muted);
  background: transparent; border: 0; border-radius: 999px; padding: 6px 13px; cursor: pointer;
}
.chip.on { background: var(--ink); color: #fff; }

.bulkbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: #fdf8e8; border: 1px solid #efe2bd; border-radius: 12px;
  padding: 10px 14px; margin-bottom: 12px; font-size: 0.94rem;
}

/* Table */
.tablewrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
table.books { border-collapse: collapse; width: 100%; font-size: 0.94rem; }
.books th, .books td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.books thead th { font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); white-space: nowrap; background: #fdfbf6; }
.books tbody tr:last-child td { border-bottom: 0; }
.books tbody tr:hover { background: #fdfbf6; }
.books tr.sel { background: #f4f7ff; }
.books th.sortable { cursor: pointer; user-select: none; }
.books th.sortable:hover { color: var(--ink); }
.books th .arrow { opacity: 0.55; }
.c-check, .c-act { width: 1%; white-space: nowrap; }
.books td.title { font-weight: 600; }
.books td.title .noauthor { font-weight: 400; color: var(--muted); font-style: italic; }
.books td.notes { max-width: 260px; color: var(--muted); }
.books td.when { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.books select.status { padding: 5px 8px; font-size: 0.88rem; border-radius: 8px; }
.pill { display: inline-block; background: var(--paper); border: 1px solid var(--line); border-radius: 999px; padding: 1px 9px; font-size: 0.8rem; margin: 0 3px 3px 0; }
.rowbtn { background: none; border: 0; font: inherit; color: var(--accent); cursor: pointer; padding: 2px 6px; font-size: 0.9rem; }
.rowbtn.del { color: #c0392b; }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; margin: 0; }

/* -------------------------------- Dialogs ---------------------------------- */
.dialog {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 0;
  background: var(--card); color: var(--ink); max-width: 520px; width: calc(100% - 32px);
}
.dialog::backdrop { background: rgba(28, 27, 25, 0.42); }
/* Long forms scroll inside the dialog instead of pushing Save off-screen. */
.dialog { max-height: 90vh; }
.dialog form { padding: 24px; display: flex; flex-direction: column; gap: 6px; max-height: 90vh; overflow-y: auto; }
.dialog h2 { margin: 0 0 4px; font-size: 1.3rem; }
.dialog label { font-weight: 600; font-size: 0.9rem; margin-top: 11px; }
/* The fieldset isn't a flex container, so these need to be blocks to stack. */
.dialog label.sub { font-weight: 500; color: var(--muted); display: block; margin-bottom: 4px; }
.conds input[type="text"] { display: block; width: 100%; }
.dialog label.inline { font-weight: 500; display: flex; align-items: center; gap: 8px; }
.dialog p { margin: 4px 0 0; }
.dialog code { background: var(--paper); border: 1px solid var(--line); border-radius: 5px; padding: 0 4px; font-size: 0.85em; }
.dialog textarea { margin-top: 8px; }
.conds { border: 1px solid var(--line); border-radius: 12px; padding: 6px 14px 14px; margin: 13px 0 0; }
.conds legend { font-weight: 600; font-size: 0.9rem; padding: 0 6px; }
.condgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 4px 10px; }
.condgrid label { display: flex; align-items: center; gap: 7px; font-weight: 500; font-size: 0.92rem; margin: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* --------------------------------- Toast ----------------------------------- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 999px;
  font-size: 0.94rem; font-weight: 500; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
  max-width: calc(100% - 40px); text-align: center; z-index: 10;
}
.toast.bad { background: #c0392b; }

@media (max-width: 700px) {
  .search { flex: 1 1 100%; }
  .toolbar .actions { margin-left: 0; }
  .books td.notes { max-width: 160px; }
  /* Keep the brand on one line and let the (long) email truncate rather than
     squeezing "Sign out" / "Privacy" off the right edge. */
  .nav { padding: 14px 20px; gap: 12px; }
  .brand { white-space: nowrap; font-size: 1.05rem; }
  .nav-right { gap: 12px; min-width: 0; }
  .nav-right .who {
    font-size: 0.82rem; max-width: 34vw;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
}
