:root {
  --bg: #f4f4f2;
  --panel: #ffffff;
  --ink: #1c1c1a;
  --muted: #6b6b66;
  --line: #e2e2dd;
  --accent: #c8102e;
  --accent-ink: #ffffff;
  --chosen: #1c1c1a;
  --photo: #2a2a28;
  --radius: 10px;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); min-height: 100vh; }
button { font: inherit; color: inherit; }
kbd {
  display: inline-block; min-width: 1.6em; padding: 1px 6px; border: 1px solid var(--line);
  border-bottom-width: 2px; border-radius: 5px; background: var(--bg); font: 600 12px/1.4 ui-monospace, monospace;
  text-align: center;
}

/* Login */
.login { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login form {
  width: min(360px, 100%); background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 28px; display: grid; gap: 14px;
}
.login h1 { margin: 0 0 4px; font-size: 20px; }
.login p { margin: 0; color: var(--muted); font-size: 14px; }
.login label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; }
.login input {
  font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg);
}
.login input:focus { outline: 2px solid var(--ink); outline-offset: -1px; }
.login button {
  padding: 11px; border: 0; border-radius: 8px; background: var(--ink); color: var(--panel);
  font-weight: 600; cursor: pointer;
}
.error { color: var(--accent); font-size: 14px; min-height: 1.2em; }

/* Review */
header {
  display: flex; align-items: center; gap: 20px; padding: 12px 24px; background: var(--panel);
  border-bottom: 1px solid var(--line);
}
header h1 { margin: 0; font-size: 16px; white-space: nowrap; }
.progress { flex: 1; display: grid; gap: 5px; max-width: 520px; }
.bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.3s; }
.progress small { color: var(--muted); font-size: 12px; }
.account { margin-left: auto; display: flex; align-items: center; gap: 14px; font-size: 14px; white-space: nowrap; }
.account a, .account button {
  color: var(--ink); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline;
  text-underline-offset: 3px; text-decoration-color: var(--line);
}

main { max-width: 1180px; margin: 0 auto; padding: 24px; display: grid; gap: 18px; }
.status { display: flex; justify-content: space-between; align-items: baseline; color: var(--muted); font-size: 14px; }
.status strong { color: var(--ink); }
.status .editing { color: var(--accent); font-weight: 600; }

.views { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
figure { margin: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; }
figure img {
  display: block; width: 100%; aspect-ratio: 1; max-height: calc(100vh - 310px); min-height: 240px;
  object-fit: contain; background: var(--photo); border-radius: 6px;
}
figcaption { padding: 8px 2px 0; font-size: 12px; color: var(--muted); }

.keys { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }
.key {
  display: flex; align-items: center; justify-content: center; gap: 10px; padding: 14px; cursor: pointer;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); font-size: 15px; font-weight: 600;
  transition: border-color 0.15s, background 0.15s;
}
.key:hover { border-color: var(--muted); }
.key.chosen { background: var(--chosen); color: var(--panel); border-color: var(--chosen); }
.key.chosen kbd { background: transparent; color: var(--panel); border-color: #55554f; }
.key:disabled { opacity: 0.4; cursor: default; }

.note { display: grid; gap: 8px; }
.note textarea {
  font: inherit; font-size: 14px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  resize: vertical; min-height: 64px; background: var(--panel);
}
.note textarea:focus { outline: 2px solid var(--ink); outline-offset: -1px; }
.note small, .hint { color: var(--muted); font-size: 13px; }
.saved-note { font-size: 14px; color: var(--ink); background: var(--panel); border: 1px dashed var(--line); border-radius: 8px; padding: 8px 12px; }

.hint { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; }

.done { text-align: center; padding: 80px 16px; }
.done h2 { margin: 0 0 8px; }
.done p { color: var(--muted); margin: 0; }
.done .hint { margin-top: 16px; }

#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--panel);
  padding: 10px 18px; border-radius: 8px; font-size: 14px; opacity: 0; transition: opacity 0.2s; pointer-events: none;
}
#toast.show { opacity: 1; }

@media (max-width: 760px) {
  header { flex-wrap: wrap; padding: 12px 16px; gap: 10px; }
  .progress { order: 3; flex-basis: 100%; max-width: none; }
  main { padding: 16px; }
  .views { grid-template-columns: 1fr; }
  figure img { max-height: none; }
  .keys { grid-template-columns: repeat(3, 1fr); }
}
