/* Lesemappe — see docs/DESIGN.md for the design system. */
@font-face { font-family: "EB Garamond"; src: url(fonts/EBGaramond-Regular.woff2) format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "EB Garamond"; src: url(fonts/EBGaramond-Italic.woff2) format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "EB Garamond"; src: url(fonts/EBGaramond-SemiBold.woff2) format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }

:root {
  --bg: #ffffff; --bg-soft: #fafaf9; --fg: #111111; --fg-2: #3a3a3a; --muted: #8a8a8a;
  --line: #ebebea; --line-strong: #d6d6d4; --focus: #111111;
  --ok: #2f7d4f; --warn: #9a6a00; --err: #b42318; --err-bg: #fdf3f2;
  --radius: 10px; --radius-sm: 7px;
  --serif: "EB Garamond", Garamond, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #141414; --bg-soft: #1c1c1c; --fg: #f2f2f2; --fg-2: #cfcfcf; --muted: #8c8c8c;
          --line: #262626; --line-strong: #3a3a3a; --focus: #f2f2f2;
          --ok: #5fbf86; --warn: #e0b44f; --err: #ff8a7a; --err-bg: #2a1a18; }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 14px/1.45 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 2px; }
a:hover { text-decoration-color: currentColor; }
p { margin: 0 0 .8em; }
.muted { color: var(--muted); }
.icon { flex: none; width: 16px; height: 16px; }
.icon-sm { width: 13px; height: 13px; }
:focus-visible { outline: 1.5px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
.js .nojs { display: none; }

/* --- App shell: sidebar + main column --- */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 30px 20px 24px; border-right: 1px solid var(--line); }
.wordmark { font: italic 400 26px/1 var(--serif); letter-spacing: -.01em; color: var(--fg); text-decoration: none; padding: 0 10px; margin: 0 0 30px; display: inline-block; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a, .nav-button { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--radius-sm); color: var(--fg-2); text-decoration: none; font: 14px/1.3 var(--sans); }
.nav a:hover, .nav-button:hover { background: var(--bg-soft); color: var(--fg); }
.nav a[aria-current] { background: var(--bg-soft); color: var(--fg); font-weight: 500; }
.nav a .icon, .nav-button .icon { color: var(--muted); }
.nav a[aria-current] .icon { color: var(--fg); }
.nav-bottom { margin: auto 0 0; }
.nav-button { width: 100%; border: 0; background: none; cursor: pointer; }
.main { padding: 44px 48px 80px; max-width: 908px; width: 100%; }
.main-bare { padding: 0 16px; }

/* --- Page header --- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 0 0 22px; }
.page-head h1, .h-serif { font: 400 34px/1.1 var(--serif); letter-spacing: -.01em; margin: 0; }
.head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.build-actions { display: flex; align-items: center; gap: 4px; }
.build-actions form { margin: 0; }

/* --- Buttons --- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: var(--radius-sm);
       font: 500 13.5px/1 var(--sans); border: 1px solid transparent; background: none; color: var(--fg); cursor: pointer; text-decoration: none; white-space: nowrap;
       transition: opacity .12s, background-color .12s; }
.btn-primary { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.btn-primary:hover { opacity: .86; }
.btn-outline { border-color: var(--fg); }
.btn-outline:hover { background: var(--bg-soft); }
.btn-text { color: var(--fg-2); padding: 0 10px; }
.btn-text:hover { color: var(--fg); background: var(--bg-soft); }
.btn:disabled { opacity: .35; cursor: default; }
.btn-text:disabled { background: none; }
.btn-xs { height: 26px; padding: 0 8px; font-size: 12.5px; font-weight: 400; gap: 5px; }
.btn-block { width: 100%; }
.btn-lg { height: 44px; font-size: 14.5px; }
.btn-link { border: 0; background: none; padding: 0; font: inherit; color: inherit; text-decoration: underline; text-decoration-color: var(--line-strong); cursor: pointer; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 6px; border: 0; background: none;
            color: var(--muted); cursor: pointer; text-decoration: none; transition: background-color .12s, color .12s; }
.icon-btn:hover { color: var(--fg); background: var(--bg-soft); }
.icon-btn-danger:hover { color: var(--err); }
.icon-btn:disabled { opacity: .3; cursor: default; background: none; color: var(--muted); }

/* --- Add panel (details popover) --- */
.add { position: relative; }
.add > summary { list-style: none; }
.add > summary::-webkit-details-marker { display: none; }
.add[open] > summary { background: var(--bg-soft); }
.add-panel { position: absolute; right: 0; top: calc(100% + 8px); z-index: 10; width: 400px; padding: 18px; background: var(--bg);
             border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 12px 32px rgba(0,0,0,.08), 0 2px 6px rgba(0,0,0,.04); }
.add-panel .upload { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }

/* --- Forms --- */
.field-group { display: flex; flex-direction: column; gap: 6px; }
label { font-size: 12.5px; color: var(--muted); }
input[type=url], input[type=password], input[type=text], select { font: 14px var(--sans); width: 100%; height: 38px; padding: 0 11px; color: var(--fg);
       background: var(--bg); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); }
input[type=file] { font: 13px var(--sans); color: var(--muted); padding: 4px 0; }
input[type=file]::file-selector-button { font: 500 12.5px var(--sans); height: 30px; padding: 0 12px; margin-right: 10px; color: var(--fg);
       background: var(--bg); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); cursor: pointer; }
input[type=file]::file-selector-button:hover { background: var(--bg-soft); }
input:focus, select:focus { outline: 1.5px solid var(--focus); outline-offset: 1px; }
select { appearance: none; padding-right: 30px; background-repeat: no-repeat; background-position: right 10px center; background-size: 12px;
         background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a8a8a' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); }
.row-fields { display: flex; gap: 8px; align-items: flex-end; margin-top: 4px; }
.row-fields .grow { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.row-fields .btn { height: 38px; }

/* --- Summary bar, job, last issue --- */
.summary { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 16px; border: 1px solid var(--line);
           border-radius: var(--radius); font-size: 13px; color: var(--fg-2); margin: 0 0 6px; }
.summary-right { color: var(--muted); font-variant-numeric: tabular-nums; }
.job, .last-issue { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; color: var(--fg-2); margin: 10px 4px 0; }
.last-issue .icon { color: var(--ok); }
.flash { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 9px 12px; margin: 10px 0; border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--fg-2); }
.flash-error { background: var(--err-bg); border-color: transparent; color: var(--err); }
.flash-ok { color: var(--fg-2); }
.main > .flash:first-child { margin-top: -20px; margin-bottom: 20px; }

/* --- Rows (queue and issues) --- */
.rows { list-style: none; margin: 14px 0 0; padding: 0; }
.row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 4px 18px; align-items: start; padding: 15px 12px; margin: 0 -12px;
       border-radius: var(--radius-sm); position: relative; }
.row + .row::before { content: ""; position: absolute; top: 0; left: 12px; right: 12px; border-top: 1px solid var(--line); }
.row:hover { background: var(--bg-soft); }
.row:hover::before, .row:hover + .row::before { border-color: transparent; }
.row-title { font: 400 19px/1.25 var(--serif); color: var(--fg); text-decoration: none; word-break: break-word; }
a.row-title:hover { text-decoration: underline; text-decoration-color: var(--line-strong); }
.row-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 0 2px; margin-top: 4px; font-size: 12.5px; color: var(--muted); }
.row-meta .src { display: inline-flex; align-items: center; gap: 5px; }
.row-meta .dot::before { content: "·"; margin: 0 6px 0 4px; }
.section-form { display: inline-flex; align-items: center; gap: 4px; margin: 0; }
.inline-select { field-sizing: content; height: 22px; width: auto; max-width: 160px; border: 0; padding: 0 16px 0 0; font-size: 12.5px; color: var(--muted); background-color: transparent;
                 background-position: right 0 center; background-size: 10px; cursor: pointer; border-radius: 4px; }
.inline-select:hover { color: var(--fg); }
.row-side { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; padding-top: 4px; font-size: 12.5px; color: var(--muted);
            font-variant-numeric: tabular-nums; white-space: nowrap; min-width: 64px; }
.row-side .num { color: var(--fg-2); }
.row-actions { display: flex; gap: 2px; padding-top: 2px; opacity: 0; transition: opacity .12s; }
.row-actions form { margin: 0; }
.row:hover .row-actions, .row:focus-within .row-actions, .row-actions-visible { opacity: 1; }
@media (hover: none) { .row-actions { opacity: 1; } }
.row-state { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 6px 0 0; font-size: 12.5px; color: var(--muted); }
.row-state form { margin: 0; }
.row-error { color: var(--err); }
.row-error .btn-text { color: var(--fg-2); }
.row-warnings { margin: 5px 0 0; padding: 0; list-style: none; font-size: 12.5px; color: var(--warn); }
.row-waiting .row-title { color: var(--fg-2); }
.state { color: var(--fg-2); }
.state-sent { color: var(--ok); }
.state-failed { color: var(--err); }
.included { margin-top: 6px; font-size: 12.5px; color: var(--muted); }
.included summary { cursor: pointer; width: fit-content; }
.included ol { margin: 6px 0 0; padding-left: 18px; color: var(--fg-2); }
.included li { margin: 2px 0; }

.empty { padding: 56px 0; text-align: center; }
.empty-title { font: 400 22px/1.3 var(--serif); margin-bottom: 6px; }

.spinner { display: inline-block; width: 11px; height: 11px; border: 1.5px solid var(--line-strong); border-top-color: var(--fg-2); border-radius: 50%;
           animation: spin .9s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } * { transition: none !important; } }

/* --- Bare pages: login, messages, bookmarklet popup --- */
.center-card { max-width: 340px; margin: 16vh auto 0; text-align: left; }
.wordmark-lg { font-size: 40px; padding: 0; margin: 0 0 8px; }
.tagline { margin: 0 0 30px; }
.center-card .field-group .btn { margin-top: 10px; }
.center-card h1 { font-size: 28px; margin: 0 0 10px; }
.capture { max-width: 460px; margin: 0 auto; padding: 22px 6px; }
.capture-head { padding-bottom: 14px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.capture-head .wordmark { padding: 0; margin: 0; font-size: 24px; }
#cap-status { display: flex; align-items: center; gap: 8px; color: var(--fg-2); }
.capture-title { font: 400 21px/1.25 var(--serif); margin: 0; }
.capture-meta { font-size: 12.5px; margin: 0; word-break: break-all; }
#cap-form label { margin-top: 10px; }
#cap-form .btn { margin-top: 14px; }
#cap-after { margin-top: 14px; }
.small-print { font-size: 12px; margin-top: 26px; }

/* --- Prose pages (bookmarklet instructions) --- */
.prose { max-width: 640px; font-size: 14.5px; color: var(--fg-2); }
.prose h2 { font: 400 22px/1.3 var(--serif); color: var(--fg); margin: 30px 0 8px; }
.prose ol, .prose ul { padding-left: 20px; }
.prose li { margin: 5px 0; }
.prose details { margin: 10px 0; }
.prose summary { cursor: pointer; color: var(--fg); }
.bookmarklet-wrap { margin: 20px 0 6px; }
.bookmarklet { cursor: grab; height: 40px; padding: 0 18px; }
textarea.code { font: 12px/1.45 ui-monospace, Menlo, monospace; width: 100%; padding: 10px; margin-top: 8px; border: 1px solid var(--line-strong);
                border-radius: var(--radius-sm); background: var(--bg-soft); color: var(--fg); word-break: break-all; }

/* --- Mobile --- */
@media (max-width: 899px) {
  .shell { display: block; }
  .sidebar { position: sticky; z-index: 20; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 4px 12px;
             padding: 14px 16px 10px; border-right: 0; border-bottom: 1px solid var(--line); background: var(--bg); }
  .wordmark { margin: 0 auto 0 0; padding: 0; font-size: 23px; }
  .nav { flex-direction: row; order: 3; width: 100%; overflow-x: auto; gap: 4px; margin: 0 -6px; }
  .nav a { padding: 6px 8px; white-space: nowrap; }
  .nav-bottom { margin: 0; }
  .nav-button span { display: none; }
  .nav-button { padding: 6px; }
  .main { padding: 24px 16px 64px; }
  .page-head h1 { font-size: 28px; }
  .head-actions { width: 100%; }
  .build-actions { margin-left: auto; }
  .add-panel { position: fixed; left: 12px; right: 12px; top: auto; width: auto; margin-top: 8px; }
  .row { grid-template-columns: minmax(0, 1fr) auto; }
  .row-actions { grid-column: 1 / -1; opacity: 1; margin-left: -6px; }
  .main > .flash:first-child { margin-top: -8px; }
}
@media (max-width: 480px) {
  .build-actions { width: 100%; justify-content: space-between; margin-left: 0; }
  .build-actions form:last-child { flex: 1; }
  .build-actions .btn-primary { width: 100%; }
}
