/* Karada Compass - シンプル和紙トーン */
:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --surface-alt: #f3efe7;
  --border: #e3dccd;
  --border-strong: #cdc4af;
  --text: #2a2520;
  --text-muted: #6c6258;
  --primary: #5b7a3d;       /* 草色 = 体・自然 */
  --primary-soft: #8baa68;
  --accent: #c8732c;        /* 茜 = 気付き */
  --gold: #b58a3b;
  --gold-bg: #f4ead2;
  --err: #c04444;
  --ok: #4a8a4a;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.06);
  --r: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

/* ===== Top bar ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 12px;
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
}
.brand-mark { font-size: 1.4em; }
.brand-text { font-weight: 700; font-size: 1.2em; color: var(--primary); }
.brand-sub { font-size: .78em; color: var(--text-muted); }

.main-nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav-link {
  padding: 6px 14px;
  text-decoration: none;
  color: var(--text-muted);
  border-radius: 6px;
  font-size: .92em;
  transition: background .15s;
}
.nav-link:hover { background: var(--surface-alt); color: var(--text); }
.nav-link.active { background: var(--primary); color: #fff; font-weight: 600; }

.right-nav { display: flex; align-items: center; gap: 8px; }
.user-pill {
  font-size: .82em;
  padding: 4px 12px;
  border-radius: 14px;
  background: var(--surface-alt);
  color: var(--text);
}

/* ===== Main / page ===== */
main {
  max-width: 720px;
  margin: 32px auto;
  padding: 0 20px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 12px;
  flex-wrap: wrap;
}
.page-header h1 { margin: 0 0 4px; font-size: 1.6em; color: var(--primary); }
.muted { color: var(--text-muted); }
.muted.small { font-size: .85em; }

.badge {
  font-size: .78em;
  padding: 4px 10px;
  border-radius: 14px;
  background: var(--gold-bg);
  color: var(--gold);
  border: 1px solid var(--gold);
}
.badge-saved { background: #e8f3df; color: var(--ok); border-color: var(--ok); }

/* ===== Karada form ===== */
.karada-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 24px 28px;
  box-shadow: var(--shadow-sm);
}
.field { border: none; padding: 0; margin: 0 0 22px; }
.field legend {
  font-weight: 700;
  font-size: 1em;
  color: var(--text);
  margin-bottom: 10px;
}
.req { color: var(--err); font-size: .72em; font-weight: 500; margin-left: 4px; }
.opt { color: var(--text-muted); font-size: .72em; font-weight: 400; margin-left: 4px; }

.choice-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.choice-row label {
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: var(--surface-alt);
  border: 1.5px solid transparent;
  border-radius: 8px;
  min-width: 70px;
  transition: all .15s;
  user-select: none;
}
.choice-row label:hover { background: #ebe6d8; }
.choice-row label.checked {
  background: #fff;
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(91, 122, 61, 0.18);
}
.choice-row input { display: none; }
.choice-row .ch { font-size: 1.3em; font-weight: 700; }
.choice-row .lbl { font-size: .75em; color: var(--text-muted); }

.choice-row.small label { min-width: 48px; padding: 8px 8px; }
.choice-row.small .ch { font-size: 1.05em; }

.ch-5, .ch-4 { color: var(--primary); }
.ch-3 { color: var(--gold); }
.ch-2, .ch-1 { color: var(--err); }

.field-row { display: flex; gap: 20px; flex-wrap: wrap; }
.field-col { flex: 1; min-width: 160px; }
.sub-label { display: block; font-size: .82em; color: var(--text-muted); margin-bottom: 6px; }
input[type="number"], input[type="text"], input[type="email"], input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-family: inherit;
  font-size: 1em;
}
input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(91,122,61,0.15); }

.form-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 20px;
}
.btn {
  padding: 10px 20px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  font-size: .95em;
  transition: all .15s;
}
.btn:hover { background: var(--surface-alt); }
.btn.primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn.primary:hover { background: #4d6932; }
.btn.big { padding: 12px 28px; font-size: 1em; font-weight: 600; }

.ok { color: var(--ok); }
.err { color: var(--err); }
.small { font-size: .85em; }

/* ===== 直近サマリ ===== */
.recent-summary {
  margin-top: 32px;
  padding: 20px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
}
.recent-summary h2 {
  margin: 0 0 12px;
  font-size: 1.1em;
  color: var(--primary);
}
.recent-list { display: flex; flex-direction: column; gap: 8px; }
.recent-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  background: var(--surface-alt);
  border-radius: 6px;
  font-size: .9em;
}
.recent-date { font-family: monospace; color: var(--text-muted); flex: 0 0 90px; }
.recent-cond { font-size: 1.2em; font-weight: 700; flex: 0 0 36px; text-align: center; }
.recent-info { color: var(--text); flex: 1; }

.link { color: var(--accent); text-decoration: none; font-weight: 500; }
.link:hover { text-decoration: underline; }

/* ===== Loop banner ===== */
.loop-banner {
  margin-top: 28px;
  padding: 16px 22px;
  background: rgba(91, 122, 61, 0.06);
  border: 1.5px dashed rgba(91, 122, 61, 0.4);
  border-radius: var(--r);
}
.loop-banner p { margin: 0 0 10px; font-size: .92em; line-height: 1.7; }
.loop-links { display: flex; gap: 10px; flex-wrap: wrap; }
.loop-links a {
  padding: 6px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  text-decoration: none;
  color: var(--text);
  font-size: .88em;
}
.loop-links a:hover { background: var(--surface-alt); }

/* ===== History ===== */
.history-list { display: flex; flex-direction: column; gap: 12px; }
.history-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px 20px;
  box-shadow: var(--shadow-sm);
}
.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.history-date { font-family: monospace; color: var(--text-muted); }
.history-cond { font-size: 1.4em; font-weight: 700; }
.history-body { display: flex; gap: 16px; font-size: .9em; color: var(--text); flex-wrap: wrap; }
.history-body .src { font-size: .78em; color: var(--text-muted); }
.history-note {
  margin: 8px 0 0;
  padding: 8px 12px;
  background: var(--surface-alt);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  font-size: .9em;
}

/* ===== Auth ===== */
.auth-container {
  max-width: 420px;
  margin: 48px auto;
  padding: 28px 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow-md);
}
.auth-container h2 { margin: 0 0 8px; color: var(--primary); }
.auth-container form input { margin-bottom: 10px; }
.auth-container button { width: 100%; }
.auth-switch { margin-top: 14px; font-size: .9em; color: var(--text-muted); text-align: center; }
.auth-switch a { color: var(--accent); }
#auth-message { margin-top: 12px; font-size: .9em; min-height: 1.2em; }

/* ===== Footer ===== */
.footer {
  margin-top: 60px;
  padding: 18px 24px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: .82em;
  color: var(--text-muted);
}

/* ===== Mobile ===== */
@media (max-width: 640px) {
  .topbar { padding: 10px 14px; }
  .brand-sub { display: none; }
  main { padding: 0 14px; margin: 20px auto; }
  .karada-form { padding: 18px 16px; }
  .choice-row label { min-width: 0; flex: 1 1 auto; padding: 8px 10px; }
  .field-row { gap: 12px; }
}
