/* Keytopia Library. Values come from the app: see docs/keytopia-library-web.md. */
:root {
  color-scheme: light dark;
  --accent: #b83345;
  --accent-text: #b83345;
  --on-accent: #fff;
  --bg: #fff;
  --panel: #f2f2f7;
  --panel-2: #e9e9ef;
  --hover: rgba(118, 118, 128, .10);
  --selected: rgba(184, 51, 69, .13);
  --fill: rgba(118, 118, 128, .12);
  --fill-strong: rgba(118, 118, 128, .2);
  --fg: #1d1d1f;
  --fg-2: rgba(60, 60, 67, .72);
  --fg-3: rgba(60, 60, 67, .46);
  --line: rgba(60, 60, 67, .16);
  --orange: #c76a00;
  --green: #248a3d;
  --red: #d70015;
  --indigo: #5856d6;
  --yellow: #d9a400;
  --shadow: 0 10px 34px rgba(0, 0, 0, .18);
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: ui-serif, "New York", Georgia, "Times New Roman", serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --accent-text: #e6606f;
    --bg: #000;
    --panel: #1c1c1e;
    --panel-2: #2c2c2e;
    --hover: rgba(118, 118, 128, .2);
    --selected: rgba(184, 51, 69, .34);
    --fill: rgba(118, 118, 128, .24);
    --fill-strong: rgba(118, 118, 128, .36);
    --fg: #f5f5f7;
    --fg-2: rgba(235, 235, 245, .68);
    --fg-3: rgba(235, 235, 245, .42);
    --line: rgba(235, 235, 245, .16);
    --orange: #ff9f0a;
    --green: #30d158;
    --red: #ff453a;
    --indigo: #7d7aff;
    --yellow: #ffd60a;
    --shadow: 0 10px 34px rgba(0, 0, 0, .6);
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 14px/1.4 var(--sans); color: var(--fg); background: var(--bg); -webkit-font-smoothing: antialiased; }
#app { height: 100%; }
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden { display: none !important; }
.noscript { padding: 48px; text-align: center; }
.muted { color: var(--fg-2); }
.faint { color: var(--fg-3); }
.small { font-size: 12px; }
.serif { font-family: var(--serif); }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon { width: 1.25em; height: 1.25em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.icon.fill { fill: currentColor; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Buttons and fields */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 32px; padding: 0 14px; border: 0; border-radius: 999px; background: var(--fill); cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { background: var(--fill-strong); }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--red); }
.btn.large { min-height: 50px; padding: 0 22px; font-size: 16px; width: 100%; }
.btn.plain { background: none; color: var(--accent-text); padding: 0 8px; }
.btn.plain:hover { background: var(--hover); }
.btn.icon-only { width: 32px; padding: 0; }
.btn:disabled { opacity: .45; cursor: default; }
.apple { background: #000; color: #fff; }
.apple:hover { background: #1d1d1f; }
@media (prefers-color-scheme: dark) { .apple { background: #fff; color: #000; } .apple:hover { background: #e8e8ed; } }
.field { width: 100%; min-height: 32px; padding: 5px 10px; border: 1px solid transparent; border-radius: 8px; background: var(--fill); outline: none; }
.field:focus { border-color: var(--accent); background: var(--bg); }
.field.capsule { border-radius: 999px; min-height: 50px; padding: 0 20px; font-size: 16px; }
.field.code { font: 600 22px var(--mono); letter-spacing: 6px; text-align: center; }
textarea.field { resize: vertical; min-height: 64px; }
label.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
input[type=checkbox] { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; }
select.field { appearance: auto; }

/* Sign-in and full-page messages */
.page-center { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 32px 24px; }
.card-narrow { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 14px; text-align: center; }
.logo { width: 72px; height: 72px; border-radius: 16px; margin: 0 auto 4px; display: block; }
.page-title { font-size: 28px; font-weight: 700; letter-spacing: -.01em; }
.or { color: var(--fg-3); font-size: 13px; }
.error { color: var(--red); font-size: 13px; }
.legal { margin-top: 12px; font-size: 12px; color: var(--fg-3); }
.legal a { color: inherit; text-decoration: underline; }
.pill-note { padding: 12px 16px; border-radius: 16px; background: var(--panel); text-align: left; font-size: 13px; }

/* Shell */
.shell { display: grid; grid-template-columns: 228px minmax(0, 1fr) 328px; grid-template-rows: minmax(0, 1fr); height: 100%; }
.shell.no-inspector { grid-template-columns: 228px minmax(0, 1fr); }
.sidebar { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.brand { display: flex; align-items: center; gap: 8px; padding: 16px 16px 10px; font-weight: 600; font-size: 15px; }
.brand img { width: 24px; height: 24px; border-radius: 6px; }
.nav { flex: 1; overflow-y: auto; padding: 0 8px 12px; }
.nav-group { margin: 14px 8px 4px; font-size: 11px; font-weight: 600; color: var(--fg-3); display: flex; align-items: center; justify-content: space-between; }
.nav-item { display: flex; align-items: center; gap: 9px; width: 100%; padding: 5px 8px; border: 0; background: none; border-radius: 7px; cursor: pointer; text-align: left; color: inherit; }
.nav-item:hover { background: var(--hover); text-decoration: none; }
.nav-item.active { background: var(--selected); color: var(--accent-text); font-weight: 500; }
.nav-item .icon { color: var(--accent-text); }
.nav-item.attention .icon { color: var(--orange); }
.nav-item.drop { outline: 2px solid var(--accent); outline-offset: -2px; }
.nav-count { margin-left: auto; font-size: 12px; color: var(--fg-3); }
.account { border-top: 1px solid var(--line); padding: 10px 12px; display: flex; align-items: center; gap: 9px; width: 100%; background: none; border-width: 1px 0 0; text-align: left; cursor: pointer; }
.account:hover { background: var(--hover); }
.avatar { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font: 500 12px ui-rounded, var(--sans); background: linear-gradient(#edc77a, #d69e4d); flex: none; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.toolbar { display: flex; align-items: center; gap: 10px; padding: 12px 20px; }
.search { position: relative; flex: 1; max-width: 340px; }
.search .icon { position: absolute; left: 10px; top: 8px; color: var(--fg-3); }
.search input { padding-left: 32px; border-radius: 999px; }
.notice { display: flex; align-items: center; gap: 10px; margin: 0 20px 10px; padding: 8px 14px; border-radius: 12px; background: var(--panel); font-size: 13px; }
.notice .icon { color: var(--accent-text); }
.page { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.page-scroll { flex: 1; overflow-y: auto; padding: 4px 20px 32px; }
.head { padding: 4px 20px 12px; display: flex; align-items: flex-end; gap: 16px; }
.head h1 { font-size: 30px; font-weight: 700; letter-spacing: -.01em; }
.head .sub { color: var(--fg-2); }
.section-title { font: 700 20px var(--serif); margin: 18px 0 10px; }
.detail-cover { width: 132px; height: 132px; flex: none; }
.empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 48px; text-align: center; color: var(--fg-2); }
.empty .icon { width: 40px; height: 40px; color: var(--fg-3); stroke-width: 1.3; }
.empty h2 { color: var(--fg); font: 700 20px var(--serif); }

/* Track table */
.table { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.thead, .tr { display: grid; align-items: center; column-gap: 12px; padding: 0 20px; }
.thead { flex: none; border-bottom: 1px solid var(--line); height: 28px; font-size: 12px; color: var(--fg-2); user-select: none; }
.thead button { all: unset; cursor: pointer; display: inline-flex; gap: 3px; align-items: center; white-space: nowrap; }
.thead button:hover { color: var(--fg); }
.thead button.on { color: var(--accent-text); font-weight: 600; }
.tbody { flex: 1; overflow-y: auto; position: relative; }
.tr { position: absolute; left: 0; right: 0; height: 48px; cursor: default; user-select: none; }
.tr:hover { background: var(--hover); }
.tr.selected { background: var(--selected); }
.tr.drop-above { box-shadow: inset 0 2px 0 var(--accent); }
.cell { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell.num { font-variant-numeric: tabular-nums; color: var(--fg-2); }
.cell.dim { color: var(--fg-2); }
.title-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.title-cell .t { min-width: 0; }
.title-cell .t1 { display: flex; align-items: center; gap: 6px; }
.title-cell .t2 { color: var(--fg-2); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { font-size: 9px; font-weight: 700; letter-spacing: .5px; padding: 1px 5px; border-radius: 999px; background: color-mix(in srgb, var(--indigo) 14%, transparent); color: var(--indigo); flex: none; }
.badge.review { background: color-mix(in srgb, var(--orange) 14%, transparent); color: var(--orange); }
.star { color: var(--yellow); }

/* Covers */
.cover { position: relative; overflow: hidden; border-radius: 8px; background: var(--fill); box-shadow: inset 0 0 0 .5px color-mix(in srgb, var(--fg) 8%, transparent); container-type: inline-size; flex: none; }
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover.thumb { width: 36px; height: 36px; border-radius: 5px; }
.gen { position: absolute; inset: 0; color: #fff; display: flex; flex-direction: column; padding: 9cqw; font-family: var(--serif); }
.gen .c { font-size: 7.5cqw; font-weight: 600; letter-spacing: .01em; text-transform: uppercase; opacity: .9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gen .r { width: 16cqw; height: max(1px, .6cqw); background: #fff; opacity: .7; margin: 3cqw 0; }
.gen .n { font-size: 11.5cqw; font-weight: 700; line-height: 1.12; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.gen .k { margin-top: auto; opacity: .55; width: 10cqw; height: 10cqw; }
.gen.small { align-items: center; justify-content: center; padding: 0; font-size: 50cqw; font-weight: 600; }

/* Grid and lists */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 20px 14px; }
.tile { all: unset; cursor: pointer; display: block; min-width: 0; }
.tile .cover { width: 100%; aspect-ratio: 1; margin-bottom: 6px; }
.tile:hover .cover { filter: brightness(1.06); }
.tile:focus-visible .cover { outline: 2px solid var(--accent); outline-offset: 2px; }
.tile .a { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .b { font-size: 13px; color: var(--fg-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-row { all: unset; display: flex; align-items: center; gap: 12px; width: 100%; box-sizing: border-box; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.list-row:hover { background: var(--hover); }
.list-row:focus-visible { outline: 2px solid var(--accent); }
.letter { font: 700 16px var(--serif); margin: 14px 10px 2px; color: var(--fg-2); }
.circle { border-radius: 50%; width: 40px; height: 40px; }

/* Inspector */
.inspector { border-left: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
.inspector .scroll { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.inspector .foot { border-top: 1px solid var(--line); padding: 10px 16px; display: flex; gap: 8px; justify-content: flex-end; }
.inspector .none { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px; text-align: center; color: var(--fg-3); }
.i-cover { position: relative; width: 148px; margin: 0 auto; }
.i-cover .cover { width: 148px; height: 148px; border-radius: 10px; box-shadow: 0 4px 8px rgba(0, 0, 0, .15); }
.i-cover .tools { display: flex; justify-content: center; gap: 4px; margin-top: 6px; }
.f { display: flex; flex-direction: column; gap: 3px; }
.f > span { font-size: 12px; color: var(--fg-2); }
.f.two { flex-direction: row; gap: 10px; }
.f.two > * { flex: 1; min-width: 0; }
.group { display: flex; flex-direction: column; gap: 10px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.group:last-child { border-bottom: 0; }
.review-box { padding: 10px 12px; border-radius: 12px; background: color-mix(in srgb, var(--orange) 12%, transparent); font-size: 12px; display: flex; flex-direction: column; gap: 6px; }
.review-box b { color: var(--orange); }
.review-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 12px; }
.kv { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; }
.kv span:first-child { color: var(--fg-2); flex: none; }
.kv span:last-child { text-align: right; min-width: 0; overflow-wrap: anywhere; }
.embedded { font: 11px var(--mono); color: var(--fg-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.combo { position: relative; }
.combo-list { position: absolute; z-index: 30; left: 0; right: 0; top: 100%; margin-top: 2px; max-height: 220px; overflow-y: auto; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 4px; }
.combo-list button { all: unset; display: block; width: 100%; box-sizing: border-box; padding: 5px 8px; border-radius: 6px; cursor: pointer; }
.combo-list button:hover, .combo-list button.on { background: var(--selected); }
.combo-list small { display: block; color: var(--fg-2); }

/* Dialogs, menus, toasts */
dialog { border: 0; border-radius: 16px; background: var(--bg); color: var(--fg); box-shadow: var(--shadow); padding: 0; width: min(480px, calc(100vw - 48px)); max-height: calc(100vh - 64px); }
dialog.wide { width: min(680px, calc(100vw - 48px)); }
dialog::backdrop { background: rgba(0, 0, 0, .35); }
.d-body { padding: 20px; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; max-height: calc(100vh - 150px); }
.d-title { font: 700 20px var(--serif); }
.d-foot { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.menu { position: fixed; z-index: 60; min-width: 190px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 4px; max-height: 60vh; overflow-y: auto; }
.menu button { all: unset; display: flex; align-items: center; gap: 8px; width: 100%; box-sizing: border-box; padding: 5px 10px; border-radius: 6px; cursor: pointer; }
.menu button:hover { background: var(--selected); }
.menu button.danger { color: var(--red); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.menu .m-label { padding: 4px 10px; color: var(--fg-2); font-size: 12px; }
.toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 70; display: flex; flex-direction: column; gap: 6px; align-items: center; }
.toast { background: var(--panel-2); padding: 8px 16px; border-radius: 999px; box-shadow: var(--shadow); font-size: 13px; }
.toast.bad { color: var(--red); }

/* Import */
.drop-veil { position: fixed; inset: 0; z-index: 50; background: color-mix(in srgb, var(--accent) 16%, transparent); display: flex; align-items: center; justify-content: center; pointer-events: none; }
.drop-veil div { padding: 28px 44px; background: var(--bg); border-radius: 22px; box-shadow: var(--shadow); font: 700 22px var(--serif); display: flex; align-items: center; gap: 12px; }
.drop-veil .icon { color: var(--accent-text); width: 28px; height: 28px; }
.progress { height: 6px; border-radius: 3px; background: var(--fill); overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); border-radius: 3px; width: 0; transition: width .2s; }
.import-panel { margin: 0 20px 10px; padding: 12px 16px; border-radius: 16px; background: var(--panel); display: flex; flex-direction: column; gap: 8px; }
.drop-zone { border: 2px dashed var(--line); border-radius: 22px; padding: 44px 24px; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; max-width: 560px; }
.drop-zone .icon { width: 40px; height: 40px; color: var(--accent-text); stroke-width: 1.3; }
.drop-zone h2 { font: 700 22px var(--serif); color: var(--fg); }
.summary-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 12px; background: var(--panel); }
.summary-row b { font-variant-numeric: tabular-nums; margin-left: auto; }
.folder-list { display: flex; flex-direction: column; gap: 4px; max-height: 220px; overflow-y: auto; }
.fail-list { font-size: 12px; max-height: 180px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.cleanup-group { padding: 12px 14px; border-radius: 16px; background: var(--panel); display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }

/* Narrower windows: the inspector floats over the list, and the sidebar slims. */
@media (max-width: 1180px) {
  .shell { grid-template-columns: 200px minmax(0, 1fr); }
  .shell.no-inspector { grid-template-columns: 200px minmax(0, 1fr); }
  .inspector { position: fixed; top: 0; bottom: 0; right: 0; width: 328px; z-index: 40; box-shadow: var(--shadow); }
  .hide-narrow { display: none !important; }
}
@media (max-width: 760px) {
  .shell, .shell.no-inspector { grid-template-columns: 56px minmax(0, 1fr); }
  .nav-item span, .brand span, .nav-group, .account .grow { display: none; }
  .brand { justify-content: center; padding: 12px 0; }
  .nav-item { justify-content: center; }
  .inspector { width: min(328px, 100vw); }
}
