/* ========== Base ========== */
*, *::before, *::after { box-sizing: border-box; }

:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-alt: #fafbfc;
  --border: #e2e6eb;
  --border-strong: #c8d0d9;
  --text: #2a2f36;
  --text-muted: #6c7684;
  --primary: #2e4057;
  --primary-hover: #1f2d3f;
  --accent: #4a7c9e;
  --gold: #c89c4a;
  --gold-bg: #f7ebd0;
  --danger: #c44a4a;
  --success: #3a8b5d;
  --shadow-sm: 0 1px 3px rgba(46, 64, 87, 0.08);
  --shadow-md: 0 4px 12px rgba(46, 64, 87, 0.10);
}

html, body { margin: 0; padding: 0; }
body {
  font-family: "Yu Gothic UI", "Hiragino Kaku Gothic ProN", "Meiryo", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  font-size: 14px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.muted { color: var(--text-muted); }
.small { font-size: 12px; }

/* ========== Topbar ========== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--primary);
  color: #fff;
  padding: 12px 24px;
  box-shadow: var(--shadow-md);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-weight: 700;
  font-size: 16px;
}
.brand:hover { text-decoration: none; }
.brand-mark { color: var(--gold); font-size: 20px; }

.topbar nav { display: flex; gap: 8px; }
.nav-link {
  color: #fff;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 13px;
  transition: background 0.15s;
}
.nav-link:hover {
  background: rgba(255, 255, 255, 0.12);
  text-decoration: none;
}
.nav-link.primary { background: var(--accent); }
.nav-link.primary:hover { background: #3d6a8c; }
.nav-link.secondary {
  border: 1px solid rgba(255, 255, 255, 0.3);
}

/* ========== Flash ========== */
.flash-area {
  max-width: 1200px;
  margin: 16px auto 0;
  padding: 0 24px;
}
.flash {
  padding: 10px 16px;
  border-radius: 6px;
  margin-bottom: 8px;
  font-size: 13px;
}
.flash-success { background: #e3f2e7; color: var(--success); border-left: 3px solid var(--success); }
.flash-error { background: #fbeaea; color: var(--danger); border-left: 3px solid var(--danger); }

/* ========== Container / Page header ========== */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}
.page-header h1 {
  margin: 0;
  font-size: 24px;
  color: var(--primary);
  font-weight: 700;
}

.back-link {
  font-size: 12px;
  color: var(--text-muted);
  display: inline-block;
  margin-bottom: 4px;
}

/* ========== List / Cards ========== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.12s, box-shadow 0.12s;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.card-official {
  border-color: var(--gold);
  background: linear-gradient(180deg, #fefbf5 0%, #ffffff 40%);
}

.card-header {
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
}
.card-title-row {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
}
.card-name {
  margin: 4px 0 2px;
  font-size: 17px;
  color: var(--primary);
}
.card-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin: 0;
}

.card-body {
  padding: 12px 16px;
  flex: 1;
}
.tagline {
  font-size: 13px;
  color: var(--text);
  margin: 0 0 10px;
  min-height: 2.6em;
}
.quote {
  margin: 0;
  padding: 8px 12px;
  border-left: 3px solid var(--accent);
  background: var(--surface-alt);
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  border-radius: 0 4px 4px 0;
}
.card-official .quote { border-left-color: var(--gold); }

.card-footer {
  padding: 10px 16px;
  background: var(--surface-alt);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.updated { font-size: 11px; color: var(--text-muted); }
.card-actions { display: flex; gap: 4px; }

/* ========== Badges ========== */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}
.badge-official { background: var(--gold-bg); color: var(--gold); }
.badge-status { background: var(--border); color: var(--text-muted); }
.status-draft { background: #edf1f5; color: #6c7684; }
.status-review { background: #fff4d6; color: #9a7b20; }
.status-完成 { background: #dff0e4; color: var(--success); }

/* ========== Buttons ========== */
.btn {
  display: inline-block;
  padding: 8px 14px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  transition: all 0.12s;
  text-decoration: none;
}
.btn:hover {
  background: var(--surface-alt);
  text-decoration: none;
  border-color: var(--accent);
}
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn.large { padding: 12px 24px; font-size: 15px; }
.btn.full { width: 100%; }
.btn.primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.danger {
  color: var(--danger);
  border-color: #e8b8b8;
}
.btn.danger:hover { background: #fbeaea; border-color: var(--danger); }
.btn.ghost {
  background: transparent;
  color: var(--text-muted);
}

/* ========== Empty state ========== */
.empty-state {
  background: var(--surface);
  border: 2px dashed var(--border-strong);
  border-radius: 10px;
  padding: 60px 30px;
  text-align: center;
  color: var(--text-muted);
}
.empty-state p { margin: 0 0 16px; }

/* ========== Form ========== */
.char-form {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 24px;
  align-items: flex-start;
}

.side-nav {
  position: sticky;
  top: 70px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 0;
}
.side-nav-header {
  padding: 0 16px 10px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.side-nav ul {
  list-style: none;
  padding: 0;
  margin: 0 0 12px;
}
.side-nav li a {
  display: block;
  padding: 7px 16px;
  color: var(--text);
  font-size: 12px;
  border-left: 2px solid transparent;
  transition: all 0.12s;
}
.side-nav li a:hover {
  background: var(--surface-alt);
  text-decoration: none;
  border-left-color: var(--accent);
}
.side-nav li a.active {
  background: #eef3f8;
  border-left-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
}
.side-nav .meta-nav { border-top: 1px solid var(--border); margin-top: 8px; padding-top: 4px; }

.side-nav-actions {
  padding: 12px 12px 0;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-main {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px 32px;
}

.form-section {
  margin-bottom: 40px;
  scroll-margin-top: 80px;
}
.form-section:last-of-type { margin-bottom: 20px; }

.section-title {
  margin: 0 0 20px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--primary);
  color: var(--primary);
  font-size: 17px;
  font-weight: 700;
}

.form-field {
  margin-bottom: 18px;
}
.form-field label {
  display: block;
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 4px;
}
.field-help {
  margin: 0 0 6px;
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.5;
}

.form-field input[type="text"],
.form-field textarea,
.form-field select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.6;
  background: var(--surface);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.form-field input[type="text"]:focus,
.form-field textarea:focus,
.form-field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(74, 124, 158, 0.15);
}

.form-field textarea {
  resize: vertical;
  min-height: 60px;
}

.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 500 !important;
}
.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
}

.meta-section {
  background: var(--surface-alt);
  padding: 20px 24px;
  border-radius: 8px;
  border-left: 3px solid var(--accent);
}

.form-footer {
  display: flex;
  gap: 12px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  margin-top: 24px;
}

/* ========== Footer ========== */
.footer {
  text-align: center;
  padding: 24px;
  font-size: 11px;
  color: var(--text-muted);
}

/* ========== Responsive ========== */
@media (max-width: 900px) {
  .char-form {
    grid-template-columns: 1fr;
  }
  .side-nav {
    position: static;
  }
  .chat-container { grid-template-columns: 1fr; }
  .chat-persona { position: static; }
}

/* ========== Topbar extensions ========== */
.brand-sub {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.6);
  font-weight: 400;
  margin-left: 4px;
}
.main-nav { display: flex; gap: 2px; flex: 1; justify-content: center; }
.main-nav .nav-link.active {
  background: rgba(255, 255, 255, 0.16);
  font-weight: 600;
}
.right-nav {
  display: flex;
  gap: 8px;
  align-items: center;
}
.admin-link {
  border: 1px solid rgba(255, 255, 255, 0.25);
  font-size: 12px;
}
.llm-badge {
  padding: 3px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.llm-badge.stub { background: #f7d98b; color: #7a5a14; }
.llm-badge.live { background: #b0dcc0; color: #1e5a34; }

/* ========== Home (書斎) ========== */
.page-home {
  background: linear-gradient(180deg, #f4ede0 0%, #f5f7fa 70%);
  min-height: 100vh;
}
.shoin {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px;
}
.shoin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 20px;
  flex-wrap: wrap;
}
.shoin-title h1 {
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: 28px;
  color: var(--primary);
  margin: 0;
  letter-spacing: 1px;
}

.today-banner {
  background: #fff;
  border-left: 4px solid var(--gold);
  padding: 20px 28px;
  border-radius: 6px;
  margin-bottom: 32px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.banner-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 2px;
  text-transform: uppercase;
}
.banner-quote {
  margin: 0;
  font-size: 18px;
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
  color: var(--primary);
  line-height: 1.6;
}
.banner-quote cite {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
  font-style: normal;
}

.desk-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}
.desk-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform 0.15s, box-shadow 0.15s;
}
.desk-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}
.desk-card-official {
  border: 1px solid var(--gold);
  background: linear-gradient(180deg, #fefbf5 0%, #ffffff 50%);
}
.desk-name {
  margin: 6px 0 2px;
  font-size: 19px;
  color: var(--primary);
  font-family: "Yu Mincho", serif;
}
.desk-meta { font-size: 11px; color: var(--text-muted); margin: 0; }
.desk-tagline { font-size: 13px; color: var(--text); margin: 4px 0 0; }
.desk-quote {
  margin: 0;
  padding: 10px 12px;
  background: var(--surface-alt);
  border-left: 3px solid var(--accent);
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  border-radius: 0 4px 4px 0;
}
.desk-card-official .desk-quote { border-left-color: var(--gold); }
.desk-actions {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.shoin-footer-links { text-align: center; padding: 30px 0 0; }
.shoin-footer-links a { font-size: 14px; color: var(--accent); }
.shoin-empty { background: #fff; }
.story {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 8px 0 0;
}

/* ========== Chat ========== */
.chat-container {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 20px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  height: calc(100vh - 120px);
}
.chat-persona {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  overflow-y: auto;
  position: sticky;
  top: 70px;
  max-height: calc(100vh - 100px);
}
.persona-name {
  margin: 8px 0 2px;
  font-size: 20px;
  color: var(--primary);
  font-family: "Yu Mincho", serif;
}
.persona-meta { font-size: 11px; color: var(--text-muted); margin: 0; }
.persona-tagline { font-size: 13px; margin: 8px 0; line-height: 1.5; }
.persona-section { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.persona-section h3 {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 1px;
  margin: 0 0 8px;
  text-transform: uppercase;
}
.persona-quotes {
  list-style: none;
  padding: 0;
  margin: 0;
}
.persona-quotes li {
  font-size: 12px;
  color: var(--text);
  font-style: italic;
  margin-bottom: 6px;
  padding: 6px 10px;
  background: var(--surface-alt);
  border-radius: 4px;
  line-height: 1.5;
}
.persona-story { font-size: 12px; line-height: 1.6; color: var(--text-muted); margin: 0; }
.persona-actions { margin-top: 16px; }

.chat-main {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chat-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
}
.chat-header h1 {
  margin: 0;
  font-size: 16px;
  color: var(--primary);
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: linear-gradient(180deg, #fafbfc 0%, #f5f7fa 100%);
}
.chat-empty {
  margin: auto;
  text-align: center;
  color: var(--text-muted);
}

.msg {
  display: flex;
  gap: 10px;
  max-width: 80%;
}
.msg-user { align-self: flex-end; flex-direction: row-reverse; }
.msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}
.msg-user .msg-avatar { background: var(--accent); }
.msg-bubble {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  line-height: 1.65;
  font-size: 14px;
  box-shadow: var(--shadow-sm);
}
.msg-user .msg-bubble { background: #eef3f8; border-color: #d4e1ec; }
.msg-summoner .msg-bubble { background: #fefbf5; border-color: #ede3d0; }
.msg-avatar-role .msg-bubble { background: #f5f2e8; font-style: italic; border-color: #e6dcc4; }
.msg-name { font-size: 11px; font-weight: 700; color: var(--text-muted); margin-bottom: 3px; }
.msg-content { white-space: pre-wrap; color: var(--text); }
.msg-time { font-size: 10px; color: var(--text-muted); margin-top: 4px; text-align: right; }

.chat-form {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: #fff;
  display: flex;
  gap: 10px;
}
.chat-form textarea {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  font-family: inherit;
  font-size: 14px;
  resize: none;
  line-height: 1.5;
}
.chat-form textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(74, 124, 158, 0.15);
}

/* ========== Reports ========== */
.page-report {
  background: linear-gradient(180deg, #f8f1e0 0%, #f5f7fa 100%);
  min-height: 100vh;
}
.report-detail {
  max-width: 780px;
  margin: 0 auto;
  padding: 24px;
}
.report-paper {
  background: #fffdf7;
  border: 1px solid #e8dcc0;
  border-radius: 6px;
  padding: 40px 48px;
  box-shadow: 0 8px 24px rgba(46, 64, 87, 0.08);
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
}
.report-head { text-align: center; margin-bottom: 24px; }
.report-greeting {
  font-size: 26px;
  color: var(--primary);
  font-weight: 700;
  letter-spacing: 2px;
}
.report-datetime { font-size: 13px; color: var(--text-muted); margin-top: 6px; }
.day-tag {
  background: var(--gold-bg);
  color: var(--gold);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
}
.report-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, #c8b994, transparent);
  margin: 24px 0;
}
.report-section { margin-bottom: 28px; }
.section-label {
  font-size: 12px;
  color: var(--gold);
  font-weight: 700;
  letter-spacing: 2px;
  margin: 0 0 12px;
  text-transform: uppercase;
}
.quote-of-day {
  margin: 0;
  padding: 18px 20px;
  background: rgba(200, 156, 74, 0.08);
  border-left: 3px solid var(--gold);
  font-size: 19px;
  line-height: 1.7;
  color: var(--primary);
  border-radius: 0 4px 4px 0;
}
.quote-of-day cite {
  display: block;
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-muted);
  font-style: normal;
  text-align: right;
  font-family: "Yu Gothic UI", sans-serif;
}
.excerpt-list { display: flex; flex-direction: column; gap: 12px; }
.excerpt {
  margin: 0;
  padding: 12px 16px;
  background: rgba(74, 124, 158, 0.05);
  border-left: 2px solid var(--accent);
  border-radius: 0 4px 4px 0;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
}
.excerpt cite {
  font-size: 11px;
  color: var(--text-muted);
  font-style: normal;
  margin-left: 8px;
  font-family: "Yu Gothic UI", sans-serif;
}
.today-action-section { text-align: center; }
.today-action {
  font-size: 17px;
  color: var(--primary);
  font-weight: 600;
  padding: 14px 20px;
  background: rgba(46, 64, 87, 0.04);
  border-radius: 6px;
  margin: 0;
}
.report-reflection, .report-intro {
  font-size: 14px;
  line-height: 1.8;
  color: var(--text);
  margin: 0 0 16px;
}
.report-reflection {
  padding: 14px 18px;
  background: rgba(46, 64, 87, 0.03);
  border-radius: 4px;
  font-style: italic;
}
.report-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid rgba(200, 185, 148, 0.3);
}
.thanked-label {
  color: var(--success);
  font-size: 14px;
  padding: 8px 16px;
  background: #e3f2e7;
  border-radius: 20px;
}
.report-debug {
  margin-top: 24px;
  padding: 12px;
  background: var(--surface);
  border-radius: 6px;
  border: 1px solid var(--border);
}
.report-debug summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--text-muted);
}

.journal-paper {
  background: #f9f6ed;
  border: 1px solid #dfd2b0;
  border-radius: 6px;
  padding: 32px 36px;
  margin-top: 24px;
  font-family: "Yu Mincho", serif;
  box-shadow: var(--shadow-sm);
}
.journal-title {
  font-size: 18px;
  color: var(--primary);
  margin: 0 0 8px;
}
.journal-date { font-size: 11px; color: var(--text-muted); margin-bottom: 16px; }
.journal-content {
  font-size: 15px;
  line-height: 2.0;
  color: #3d3527;
  white-space: pre-wrap;
}

/* Reports list */
.report-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.report-card {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 20px;
  padding: 18px 24px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
  transition: transform 0.12s, box-shadow 0.12s;
}
.report-card:hover {
  transform: translateX(2px);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  border-color: var(--gold);
}
.report-date {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding-right: 20px;
  border-right: 1px solid var(--border);
}
.date-day {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
  font-family: "Yu Mincho", serif;
}
.date-month { font-size: 11px; color: var(--text-muted); }
.report-body blockquote {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--primary);
  font-family: "Yu Mincho", serif;
}
.report-body cite {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  font-style: normal;
}
.report-action {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--accent);
}
.badge-day1 { background: #ffe9b8; color: #876210; }
.badge-daynum { background: #eef3f8; color: var(--accent); }
.badge-thanked { background: transparent; font-size: 14px; }
.badge-active { background: var(--success); color: white; }

/* ========== Journal list ========== */
.journal-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.journal-entry {
  background: #f9f6ed;
  border: 1px solid #dfd2b0;
  border-radius: 6px;
  padding: 24px 32px;
  font-family: "Yu Mincho", serif;
}
.journal-entry-date {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
  letter-spacing: 2px;
}
.journal-entry-content {
  font-size: 15px;
  line-height: 2.0;
  color: #3d3527;
}

/* ========== Settings ========== */
.settings-container { max-width: 700px; }
.settings-form {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 28px 32px;
}
.settings-info {
  margin-top: 20px;
  padding: 20px 24px;
  background: var(--surface-alt);
  border-radius: 8px;
  border-left: 3px solid var(--accent);
}
.settings-info h2 {
  margin: 0 0 12px;
  font-size: 14px;
  color: var(--primary);
}
.info-list { margin: 0; font-size: 13px; }
.info-list dt { font-weight: 700; margin-top: 8px; color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; }
.info-list dd { margin: 2px 0 8px; color: var(--text); }
.info-list code { background: var(--surface); padding: 2px 6px; border-radius: 3px; font-size: 11px; }

/* ========== Admin toolbar ========== */
.page-admin {
  background: #f2f4f7;
}
.admin-toolbar {
  background: #fef5e0;
  border: 1px solid #f0d9a3;
  border-radius: 6px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.admin-label {
  font-size: 12px;
  font-weight: 700;
  color: #8a6620;
  letter-spacing: 1px;
}
.admin-toolbar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ================================================================
   Responsive — Tablet (≤900px) と Mobile (≤600px)
   既存の @media (max-width: 900px) は char-form / side-nav / chat 用。
   ここでは topbar / grid / forms / settings 連携パネルを追補。
   ================================================================ */

/* ---- ≤900px: タブレット ---- */
@media (max-width: 900px) {
  .container { padding: 16px; }
  .shoin { padding: 24px 16px; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
  .topbar { padding: 10px 16px; }
  .brand-sub { display: none; }
}

/* ---- ≤600px: モバイル(iPhone/Android 主要サイズ) ---- */
@media (max-width: 600px) {
  /* ---- Topbar: 縦並び + 水平スクロールナビ ---- */
  .topbar {
    flex-wrap: wrap;
    padding: 8px 12px;
    gap: 8px;
  }
  .brand {
    font-size: 14px;
    gap: 6px;
  }
  .brand-mark { font-size: 16px; }
  .main-nav {
    order: 3;
    flex: 1 0 100%;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 2px;
    justify-content: flex-start;
    padding: 4px 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }
  .main-nav::-webkit-scrollbar { height: 3px; }
  .main-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.3); }
  .main-nav .nav-link {
    padding: 6px 10px;
    font-size: 12px;
    white-space: nowrap;
    flex-shrink: 0;
  }
  .right-nav { gap: 4px; flex-shrink: 0; }
  .right-nav .nav-link {
    padding: 6px 8px;
    font-size: 12px;
  }
  .llm-badge { font-size: 9px; padding: 2px 6px; }
  .dev-user-pill { font-size: 10px !important; padding: 2px 8px !important; }

  /* ---- Containers / Layouts ---- */
  .container, .flash-area { padding: 12px; }
  .shoin { padding: 16px 12px; }
  .card-grid,
  .summon-grid,
  .features,
  .stats-grid,
  .form-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  /* ---- Headings / Typography ---- */
  body { font-size: 14px; }
  h1 { font-size: 1.4rem; }
  h2 { font-size: 1.15rem; }
  h3 { font-size: 1.05rem; }
  .page-header h1 { font-size: 20px; }
  .shoin-title h1 { font-size: 1.5rem; }

  /* ---- Forms: iOS の auto-zoom 防止 (≥16px) + フル幅 ---- */
  .form-field input[type="text"],
  .form-field input[type="email"],
  .form-field input[type="password"],
  .form-field input[type="time"],
  .form-field input[type="number"],
  .form-field textarea,
  .form-field select {
    font-size: 16px;
    width: 100%;
    box-sizing: border-box;
  }
  .form-field label { font-size: 14px; }
  .field-help { font-size: 12px; }

  /* ---- Buttons: タップターゲット 40px 以上 ---- */
  .btn, button {
    min-height: 40px;
    font-size: 13px;
  }
  .btn.large { padding: 10px 18px; font-size: 14px; }
  .form-footer { display: flex; flex-direction: column; gap: 8px; }
  .form-footer .btn { width: 100%; }

  /* ---- Settings 連携パネル(T1-13)の縦積み ---- */
  .settings-info { padding: 0 !important; }
  .link-card > div:first-child {
    flex-direction: column !important;
    align-items: stretch !important;
  }
  .link-card a.btn,
  .link-card a[class*="secondary"] {
    width: 100%;
    text-align: center;
  }

  /* ---- Cards / Reports ---- */
  .card { border-radius: 8px; }
  .card-header, .card-body, .card-footer { padding: 12px; }
  .report-card { padding: 12px; }

  /* ---- Footer ---- */
  .footer { font-size: 10px; padding: 16px 12px; text-align: center; }

  /* ---- Flash ---- */
  .flash { font-size: 12px; padding: 8px 12px; }

  /* ---- Admin toolbar / actions: 折り返し許容 ---- */
  .admin-toolbar-actions { gap: 6px; }

  /* ---- Tables: 横スクロール ---- */
  table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

/* ---- ≤380px: 小型端末(iPhone SE 等) ---- */
@media (max-width: 380px) {
  .brand-sub { display: none; }
  .main-nav .nav-link { padding: 5px 8px; font-size: 11px; }
  .right-nav .nav-link { padding: 5px 6px; font-size: 11px; }
  .llm-badge, .dev-user-pill { display: none; }
}
