:root {
  --ink: #14213d;
  --bg: #faf9f6;
  --card: #ffffff;
  --border: #e3e3e8;
  --accent: #2a6df4;
  --error: #d1453b;
  --success: #1a8a4e;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Hiragino Sans", "Yu Gothic", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; text-decoration: none; color: var(--ink); }
.topbar nav { display: flex; gap: 16px; align-items: center; }
.topbar nav a { color: var(--ink); text-decoration: none; }
.topbar nav a:hover { color: var(--accent); }
.user { color: #888; font-size: 0.9em; }

.container { max-width: 860px; margin: 0 auto; padding: 24px; }

.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }

.btn {
  display: inline-block;
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  font-size: 1em;
}
.btn-primary { background: var(--accent); color: white; border-color: var(--accent); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 10px; }
.flash-error { background: #fdeceb; color: var(--error); }
.flash-success { background: #eaf7ef; color: var(--success); }

.login-card { max-width: 420px; margin: 80px auto; text-align: center; background: var(--card); padding: 32px; border-radius: 12px; border: 1px solid var(--border); }
.google-btn { display: inline-block; margin-top: 16px; padding: 12px 24px; background: var(--ink); color: white; text-decoration: none; border-radius: 8px; }
.note { color: #888; font-size: 0.85em; margin-top: 16px; }

.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.project-card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 16px; text-decoration: none; color: var(--ink); }
.project-card .status { font-size: 0.85em; color: #888; margin-bottom: 8px; }
.project-card.static { display: flex; flex-direction: column; gap: 8px; }
.by { color: #888; font-size: 0.85em; }

.progress-bar { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; margin: 6px 0; }
.progress-bar.large { height: 12px; }
.progress-fill { height: 100%; background: var(--accent); }
.progress-label { font-size: 0.85em; color: #888; margin: 0 0 16px; }

.form-card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 24px; max-width: 480px; }
.form-card label { display: block; font-weight: 600; margin: 16px 0 6px; }
.form-card input[type="text"] { width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 1em; }
.preset-list { display: flex; flex-direction: column; gap: 8px; }
.preset-option { display: flex; align-items: center; gap: 8px; border: 1px solid var(--border); border-radius: 8px; padding: 10px; cursor: pointer; }
.preset-count { margin-left: auto; color: #888; font-size: 0.85em; }
.form-card button { margin-top: 20px; width: 100%; }

.char-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; margin-top: 16px; }
.char-cell {
  aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: 6px;
  text-decoration: none; color: var(--ink);
  background: var(--card); font-size: 1.1em;
}
.char-cell.done { background: #eaf7ef; border-color: var(--success); }

.callout { padding: 14px 18px; border-radius: 8px; margin: 16px 0; }
.callout-success { background: #eaf7ef; color: var(--success); }
.callout-error { background: #fdeceb; color: var(--error); white-space: pre-wrap; }

.draw-head h1 { margin-bottom: 4px; }
.codepoint { color: #888; font-size: 0.5em; margin-left: 8px; }
.back-link { color: #888; text-decoration: none; font-size: 0.9em; }

.draw-toolbar { display: flex; gap: 12px; align-items: center; margin: 12px 0; flex-wrap: wrap; }
.draw-toolbar button { padding: 8px 14px; border-radius: 6px; border: 1px solid var(--border); background: var(--card); cursor: pointer; }
.smoothing-toggle { display: flex; align-items: center; gap: 6px; font-size: 0.9em; }
.pen-thickness-control { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 0.9em; }
.pen-thickness-control input[type="range"] { width: 120px; }

.canvas-wrap { display: flex; justify-content: center; }
#drawCanvas {
  width: 400px; height: 400px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
  touch-action: none;
  cursor: crosshair;
}

.draw-actions { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; margin-top: 16px; }
.draw-actions .btn:last-child, .draw-actions a:last-child { justify-self: end; }
.save-status { text-align: center; color: #888; min-height: 1.2em; }

.empty { color: #888; }

.head-actions { display: flex; gap: 10px; align-items: center; }
.head-actions form { display: inline; }

.download-row { display: flex; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.callout { padding: 14px 18px; background: var(--card); border: 1px solid var(--border); border-radius: 8px; margin: 16px 0; }

.form-card.wide { max-width: 640px; }
.form-card textarea {
  width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 1em; font-family: inherit; resize: vertical;
}
.total-count { margin-top: 14px; font-weight: 600; color: var(--accent); }

.draw-body { display: flex; gap: 20px; justify-content: center; align-items: flex-start; margin-top: 12px; flex-wrap: wrap; }
.side-preview-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 130px; }
.side-preview-empty { width: 130px; }
.mini-preview-label { font-size: 0.8em; color: #888; margin: 0; text-align: center; }
#miniPreview { width: 80px; height: 80px; border: 1px solid var(--border); border-radius: 6px; background: white; }
#miniPreviewSmall { width: 36px; height: 36px; border: 1px solid var(--border); border-radius: 4px; background: white; }
#prevCharPreview { width: 130px; height: 130px; border: 1px solid var(--border); border-radius: 8px; background: white; opacity: 0.85; }
.text-link { font-size: 0.8em; color: var(--accent); text-decoration: none; text-align: center; }

.preview-page textarea#previewText {
  width: 100%; padding: 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 1.1em; font-family: inherit; resize: vertical; margin: 12px 0;
}
.preview-toolbar { display: flex; gap: 24px; align-items: center; margin-bottom: 12px; font-size: 0.9em; }
.preview-canvas-wrap { display: flex; justify-content: center; }
#previewCanvas { width: 100%; max-width: 800px; height: auto; border: 1px solid var(--border); border-radius: 8px; background: white; }
