:root {
  --accent: #1f4e79;
  --accent-light: #2ea0ff;
  --bg: #f3f5f8;
  --card: #fff;
  --text: #1b1f24;
  --muted: #6b7480;
  --danger: #c0392b;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; padding-bottom: env(safe-area-inset-bottom); }
h1, h2 { margin: 0 0 12px; }
h2 { font-size: 1.1rem; }

button, .big-button {
  font: inherit;
  border: 1px solid #c9d0d8;
  background: #fff;
  color: var(--text);
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
}
button.primary, .big-button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.link, a.link { background: none; border: none; color: inherit; padding: 4px 6px; text-decoration: underline; cursor: pointer; font: inherit; }

input, textarea {
  font: inherit;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #c9d0d8;
  border-radius: 8px;
  margin-top: 4px;
}
label { display: block; margin-bottom: 12px; font-size: .95rem; }
p.label { margin: 0 0 6px; font-size: .95rem; }
dialog .segmented { margin-bottom: 16px; }
label.radio { display: flex; gap: 8px; align-items: center; }
label.radio input { width: auto; margin: 0; }

.card { background: var(--card); border-radius: 14px; padding: 18px; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.error { color: var(--danger); }

.login { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login form { width: 100%; max-width: 360px; }
.login button { width: 100%; }

.bar {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--accent); color: #fff;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
}
.bar .link { color: #fff; font-size: .9rem; }
.bar .title { font-weight: 700; font-size: 1rem; text-decoration: none; padding: 0; }

main#app { max-width: 720px; margin: 0 auto; padding: 16px; }
.step { display: flex; flex-direction: column; gap: 12px; }
.step[hidden] { display: none; }

.big-button { display: block; text-align: center; padding: 18px; font-size: 1.1rem; width: 100%; }

.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > * { flex: 1 1 auto; }
.row.between { justify-content: space-between; align-items: center; }
.row.between > * { flex: 0 0 auto; }
h1 { font-size: 1.4rem; margin: 0; }
h2.sub { margin-top: 18px; }
select { font: inherit; width: 100%; padding: 10px 12px; border: 1px solid #c9d0d8; border-radius: 8px; margin-top: 4px; background: #fff; }
input[readonly] { background: #f0f2f5; color: var(--muted); }
#step-settings .card { display: flex; flex-direction: column; }
#step-settings .card > button.primary { align-self: flex-start; }
#admin-settings { display: flex; flex-direction: column; gap: 12px; }
.users { list-style: none; margin: 0 0 8px; padding: 0; }
.users li { display: flex; align-items: center; gap: 4px; padding: 8px 0; border-bottom: 1px solid #e3e7ec; }
.users .grow { flex: 1; }
button.link.danger { color: var(--danger); }

.hint { margin: 0; color: var(--muted); }
.crop-wrap { display: flex; justify-content: center; }
#crop-canvas { touch-action: none; border-radius: 6px; max-width: 100%; }

.thumbs { display: flex; gap: 8px; overflow-x: auto; }
.thumbs canvas { border: 1px solid #ccd; border-radius: 4px; background: #fff; }

.segmented { display: flex; background: #e3e7ec; border-radius: 10px; padding: 3px; }
.segmented label { flex: 1; margin: 0; }
.segmented input { position: absolute; opacity: 0; width: 0; }
.segmented span { display: block; text-align: center; padding: 8px; border-radius: 8px; cursor: pointer; }
.segmented input:checked + span { background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.15); font-weight: 600; }

.preview { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
.preview figure { margin: 0; text-align: center; }
.preview canvas { display: block; margin: 0 auto; max-width: 100%; max-height: 32vh; width: auto; height: auto; box-shadow: 0 1px 6px rgba(0,0,0,.2); background: #fff; }
.preview figcaption { color: var(--muted); font-size: .85rem; margin-top: 4px; }

dialog { border: none; border-radius: 14px; padding: 18px; width: min(92vw, 400px); }
dialog.wide { width: min(94vw, 560px); }
.archive { list-style: none; margin: 0 0 14px; padding: 0; max-height: 60vh; overflow-y: auto; }
.archive li { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid #e3e7ec; }
.archive li { gap: 12px; }
.archive .thumb {
  flex: 0 0 64px; height: 84px; display: grid; place-items: center; overflow: hidden;
  border: 1px solid #d5dbe2; border-radius: 4px; background: #f7f8fa;
  color: var(--muted); font-size: .75rem; font-weight: 700; text-decoration: none;
}
.archive .thumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.archive .meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.archive a.name { color: var(--accent); word-break: break-all; }
.archive small { color: var(--muted); }
.archive .empty { color: var(--muted); border: none; }
dialog::backdrop { background: rgba(0,0,0,.4); }

.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: #1e7e34; color: #fff; padding: 12px 18px; border-radius: 10px;
  box-shadow: 0 4px 14px rgba(0,0,0,.25); max-width: 90vw; z-index: 20;
}
.toast.error { background: var(--danger); }

.busy { position: fixed; inset: 0; background: rgba(255,255,255,.6); display: grid; place-items: center; z-index: 10; }
.spinner { width: 44px; height: 44px; border: 4px solid #cfd8e3; border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#step-settings .segmented { margin-bottom: 14px; }

.folders { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip { padding: 6px 10px; border-radius: 999px; font-size: .9rem; }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.folder-actions { margin-bottom: 6px; }
.folder-actions button { flex: 0 0 auto; padding: 6px 10px; font-size: .9rem; }
.danger-outline { color: var(--danger); border-color: var(--danger); }
.archive select.move { width: auto; margin-top: 4px; padding: 4px 6px; font-size: .85rem; }
