/* ══════════════════════════════════════════════════════════════════
   TimePersona — Design System v2
   一つの真実の源 (single source of truth)
   全ページから <link rel="stylesheet" href="tokens.css"> で参照
   ══════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;500;600;700;800&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* ── COLORS ──────────────────────────────────────────────*/

  /* Surfaces (warm-tinted neutrals, ほぼ白) */
  --bg:            #fafaf8;   /* ページ背景 */
  --surface:       #ffffff;   /* カード */
  --surface-alt:   #f5f5f2;   /* 内陷・区别 */
  --surface-sunk:  #ebebe6;   /* より深い凹み */

  /* Text */
  --text:          #1c1b1a;   /* 主文字 */
  --text-muted:    #6b6a67;   /* 次文字 */
  --text-subtle:   #a3a19d;   /* ヒント */

  /* Borders */
  --border:        #e7e5e0;   /* 默认 */
  --border-strong: #d6d3cd;   /* hover / focus 内 */

  /* Brand (去紫色化: iris 深靛蓝) */
  --brand:         #3a3aa4;
  --brand-hover:   #2e2e8a;
  --brand-soft:    #eeeeff;   /* brand 淡底 */
  --brand-ink:     #1f1f6b;   /* brand 上的深色文字 */

  /* Accent (logo .jp.ai 上标专用 — 琥珀金 / 有识别度但不喧宾夺主) */
  --accent:        #b45309;
  --accent-soft:   #fef3e8;

  /* Semantic (仅功能性使用 — 成功/警告/错误/信息) */
  --success:       #15803d;
  --success-soft:  #ecfdf5;
  --warn:          #b45309;
  --warn-soft:     #fef3e8;
  --danger:        #b91c1c;
  --danger-soft:   #fef2f2;
  --info:          #1d4ed8;
  --info-soft:     #eff6ff;

  /* ── TYPOGRAPHY ──────────────────────────────────── */
  --font-sans:  "Inter", "Noto Sans JP", "Hiragino Kaku Gothic ProN",
                "Hiragino Sans", "Yu Gothic", -apple-system, BlinkMacSystemFont,
                "Segoe UI", sans-serif;
  --font-jp:    "Noto Sans JP", "Hiragino Kaku Gothic ProN",
                "Hiragino Sans", "Yu Gothic", sans-serif;
  --font-mono:  "JetBrains Mono", "SF Mono", "Monaco", "Menlo", monospace;

  --fs-xs:   11px;
  --fs-sm:   13px;
  --fs-base: 14px;
  --fs-md:   15px;
  --fs-lg:   17px;
  --fs-xl:   20px;
  --fs-2xl:  26px;
  --fs-3xl:  34px;
  --fs-4xl:  44px;

  --lh-tight: 1.3;
  --lh-base:  1.55;
  --lh-loose: 1.75;

  /* ── SPACING (4px baseline) ──────────────────────── */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;
  --sp-16: 64px;

  /* ── RADIUS ──────────────────────────────────────── */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-pill: 999px;

  /* ── SHADOW (控制在极弱水平,卡片靠 border 分隔) */
  --shadow-xs: 0 1px 2px rgba(28, 27, 26, 0.04);
  --shadow-sm: 0 2px 6px rgba(28, 27, 26, 0.06);
  --shadow-md: 0 6px 20px rgba(28, 27, 26, 0.08);

  /* ── LAYOUT ──────────────────────────────────────── */
  --header-h: 56px;
  --bottom-nav-h: 56px;
  --container-narrow: 720px;
  --container-base:   900px;
  --container-wide:   1100px;

  --z-header: 50;
  --z-modal:  100;
  --z-toast:  200;
}

/* ══════════════════════════════════════════════════════════
   RESET & BASE
   ══════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding-bottom: calc(var(--bottom-nav-h) + var(--sp-4));
}
@media (min-width: 768px) {
  body { padding-bottom: var(--sp-8); }
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; }
input, textarea, select { font-family: inherit; }

::selection { background: var(--brand-soft); color: var(--brand-ink); }

/* ══════════════════════════════════════════════════════════
   HEADER — 全ページ共通
   ══════════════════════════════════════════════════════════ */
.tp-header {
  position: sticky;
  top: 0;
  height: var(--header-h);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: var(--z-header);
  display: flex;
  align-items: center;
  padding: 0 var(--sp-6);
  gap: var(--sp-4);
}
.tp-header--dark {
  background: rgba(20, 20, 24, 0.85);
  border-bottom-color: rgba(255,255,255,0.08);
}

.tp-logo {
  font-family: var(--font-sans);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  align-items: baseline;
}
.tp-logo:hover { text-decoration: none; opacity: 0.8; }
.tp-logo__mark { color: var(--text); }
.tp-logo__tld {
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  margin-left: 2px;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--accent-soft);
  letter-spacing: 0.02em;
  position: relative;
  top: -6px;
}
.tp-header--dark .tp-logo__mark { color: #fff; }

.tp-header__spacer { flex: 1; }

.tp-nav {
  display: none;
  align-items: center;
  gap: 2px;
}
@media (min-width: 720px) {
  .tp-nav { display: flex; }
}

.tp-nav__link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.tp-nav__link:hover {
  background: var(--surface-alt);
  color: var(--text);
  text-decoration: none;
}
.tp-nav__link.is-active {
  color: var(--brand);
  background: var(--brand-soft);
}
.tp-header--dark .tp-nav__link { color: rgba(255,255,255,0.65); }
.tp-header--dark .tp-nav__link:hover { background: rgba(255,255,255,0.08); color: #fff; }

/* ══════════════════════════════════════════════════════════
   BOTTOM NAV (モバイル)
   ══════════════════════════════════════════════════════════ */
.tp-bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bottom-nav-h);
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: var(--z-header);
}
@media (min-width: 720px) {
  .tp-bottom-nav { display: none; }
}
.tp-bottom-nav__link {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
}
.tp-bottom-nav__link.is-active { color: var(--brand); }
.tp-bottom-nav__link:hover { text-decoration: none; }
.tp-bottom-nav__icon {
  width: 20px; height: 20px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 18px;
  line-height: 1;
}

/* ══════════════════════════════════════════════════════════
   LAYOUT
   ══════════════════════════════════════════════════════════ */
.tp-page {
  max-width: var(--container-base);
  margin: 0 auto;
  padding: var(--sp-8) var(--sp-5);
}
.tp-page--narrow { max-width: var(--container-narrow); }
.tp-page--wide   { max-width: var(--container-wide); }

.tp-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-sm);
  color: var(--text-muted);
  margin-bottom: var(--sp-5);
}
.tp-breadcrumb a { color: var(--text-muted); }
.tp-breadcrumb a:hover { color: var(--brand); }
.tp-breadcrumb__sep { color: var(--text-subtle); }

/* Section heading */
.tp-h1 {
  font-size: var(--fs-3xl);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--text);
}
.tp-h2 {
  font-size: var(--fs-2xl);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--text);
}
.tp-h3 {
  font-size: var(--fs-xl);
  font-weight: 700;
  line-height: 1.3;
  color: var(--text);
}
.tp-h4 {
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--text);
}
.tp-muted { color: var(--text-muted); }
.tp-subtle { color: var(--text-subtle); }
.tp-mono { font-family: var(--font-mono); }

.tp-section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
  margin: var(--sp-8) 0 var(--sp-4);
}
.tp-section-title__label {
  font-size: var(--fs-sm);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

/* ══════════════════════════════════════════════════════════
   CARD — 基本
   ══════════════════════════════════════════════════════════ */
.tp-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-6);
}
.tp-card--inset {
  background: var(--surface-alt);
  border: 1px solid var(--border);
}
.tp-card--hover {
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.tp-card--hover:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

/* ══════════════════════════════════════════════════════════
   BUTTONS — 三段階 (primary / secondary / ghost)
   ══════════════════════════════════════════════════════════ */
.tp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  font-family: inherit;
  font-size: var(--fs-base);
  font-weight: 600;
  line-height: 1;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}
.tp-btn:hover { text-decoration: none; }
.tp-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Primary */
.tp-btn--primary {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}
.tp-btn--primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); color: #fff; }

/* Secondary (outline) */
.tp-btn--secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}
.tp-btn--secondary:hover { background: var(--surface-alt); border-color: var(--text-muted); }

/* Ghost */
.tp-btn--ghost {
  background: transparent;
  color: var(--text-muted);
}
.tp-btn--ghost:hover { background: var(--surface-alt); color: var(--text); }

/* Sizes */
.tp-btn--sm { padding: 6px 12px; font-size: var(--fs-sm); }
.tp-btn--lg { padding: 12px 24px; font-size: var(--fs-md); }
.tp-btn--block { width: 100%; }

/* ══════════════════════════════════════════════════════════
   BADGE / CHIP / TAG
   ══════════════════════════════════════════════════════════ */
.tp-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  font-size: var(--fs-xs);
  font-weight: 600;
  line-height: 1.5;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  white-space: nowrap;
}
.tp-badge--brand   { background: var(--brand-soft); color: var(--brand-ink); border-color: transparent; }
.tp-badge--success { background: var(--success-soft); color: var(--success); border-color: transparent; }
.tp-badge--warn    { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.tp-badge--danger  { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.tp-badge--info    { background: var(--info-soft); color: var(--info); border-color: transparent; }
.tp-badge--persona { background: #f5f2ea; color: #6a4d16; border-color: #ddd4c0; } /* 武将 — 纸色 */

.tp-badge__dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
}

.tp-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: var(--fs-xs);
  color: var(--text-muted);
  background: var(--surface-alt);
  border-radius: var(--r-sm);
  font-weight: 500;
}
.tp-tag::before { content: '#'; color: var(--text-subtle); margin-right: 1px; }

/* ══════════════════════════════════════════════════════════
   FORM
   ══════════════════════════════════════════════════════════ */
.tp-field { margin-bottom: var(--sp-4); }
.tp-label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.tp-label__hint {
  display: inline;
  font-weight: 400;
  color: var(--text-muted);
  margin-left: 6px;
}
.tp-input, .tp-textarea, .tp-select {
  width: 100%;
  padding: 10px 12px;
  font-family: inherit;
  font-size: var(--fs-base);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.tp-input:focus, .tp-textarea:focus, .tp-select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.tp-input[readonly], .tp-input:disabled {
  background: var(--surface-alt);
  color: var(--text-muted);
}
.tp-textarea { resize: vertical; min-height: 96px; line-height: var(--lh-base); }

.tp-help {
  margin-top: 6px;
  font-size: var(--fs-xs);
  color: var(--text-muted);
  line-height: 1.5;
}

/* ══════════════════════════════════════════════════════════
   AVATAR
   ══════════════════════════════════════════════════════════ */
.tp-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--surface-alt);
  color: var(--text);
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  overflow: hidden;
}
.tp-avatar--sm { width: 28px; height: 28px; font-size: 12px; }
.tp-avatar--lg { width: 52px; height: 52px; font-size: 19px; }
.tp-avatar--brand { background: var(--brand); color: #fff; border-color: transparent; }

/* ══════════════════════════════════════════════════════════
   ALERT
   ══════════════════════════════════════════════════════════ */
.tp-alert {
  padding: 12px 14px;
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  line-height: 1.6;
  border: 1px solid;
}
.tp-alert--success { background: var(--success-soft); border-color: #bbf7d0; color: var(--success); }
.tp-alert--warn    { background: var(--warn-soft); border-color: #fcd9a8; color: var(--warn); }
.tp-alert--danger  { background: var(--danger-soft); border-color: #fecaca; color: var(--danger); }
.tp-alert--info    { background: var(--info-soft); border-color: #bfdbfe; color: var(--info); }

/* ══════════════════════════════════════════════════════════
   STATES — loading / empty
   ══════════════════════════════════════════════════════════ */
.tp-loading {
  text-align: center;
  padding: var(--sp-10) var(--sp-4);
  color: var(--text-muted);
  font-size: var(--fs-sm);
}
.tp-loading::after {
  content: '...';
  display: inline-block;
  animation: tp-dots 1.4s steps(4, end) infinite;
  width: 1.2em;
  text-align: left;
}
@keyframes tp-dots {
  0%   { content: ''; }
  25%  { content: '.'; }
  50%  { content: '..'; }
  75%  { content: '...'; }
}

.tp-empty {
  text-align: center;
  padding: var(--sp-12) var(--sp-5);
  color: var(--text-muted);
}
.tp-empty__title {
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.tp-empty__desc { font-size: var(--fs-sm); }

/* ══════════════════════════════════════════════════════════
   FOOTER
   ══════════════════════════════════════════════════════════ */
.tp-footer {
  margin-top: var(--sp-12);
  padding: var(--sp-6) var(--sp-5);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--sp-3);
  font-size: var(--fs-xs);
  color: var(--text-muted);
}
.tp-footer__links { display: flex; gap: var(--sp-5); flex-wrap: wrap; }
.tp-footer__links a { color: var(--text-muted); }
.tp-footer__links a:hover { color: var(--brand); }

/* ══════════════════════════════════════════════════════════
   UTILS
   ══════════════════════════════════════════════════════════ */
.tp-stack   { display: flex; flex-direction: column; }
.tp-stack-1 { gap: var(--sp-1); } .tp-stack-2 { gap: var(--sp-2); }
.tp-stack-3 { gap: var(--sp-3); } .tp-stack-4 { gap: var(--sp-4); }
.tp-stack-6 { gap: var(--sp-6); }

.tp-row     { display: flex; align-items: center; }
.tp-row-gap-2 { gap: var(--sp-2); } .tp-row-gap-3 { gap: var(--sp-3); }
.tp-row-gap-4 { gap: var(--sp-4); }

.tp-flex-spacer { flex: 1; }
.tp-hide-mobile { display: none; }
@media (min-width: 720px) { .tp-hide-mobile { display: initial; } .tp-hide-desktop { display: none; } }

/* Divider */
.tp-divider {
  height: 1px;
  background: var(--border);
  margin: var(--sp-5) 0;
  border: 0;
}

/* Modal (シンプル) */
.tp-modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(28, 27, 26, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4);
  z-index: var(--z-modal);
  animation: tp-fade 0.15s ease-out;
}
.tp-modal {
  background: var(--surface);
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  animation: tp-rise 0.2s ease-out;
}
.tp-modal__header {
  padding: var(--sp-5) var(--sp-6);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.tp-modal__title { font-size: var(--fs-lg); font-weight: 700; }
.tp-modal__close {
  background: none; border: none;
  font-size: 20px; color: var(--text-muted); cursor: pointer;
  line-height: 1; padding: 4px;
}
.tp-modal__body   { padding: var(--sp-6); }
.tp-modal__footer { padding: var(--sp-4) var(--sp-6); border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: var(--sp-2); }

@keyframes tp-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes tp-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
