:root {
  --ink: #132f42;
  --ink-soft: #48606d;
  --blue-deep: #0f3447;
  --blue-light: #dce8ea;
  --tea: #a86543;
  --tea-dark: #80462f;
  --tea-pale: #f4e8dc;
  --cream: #f8f4eb;
  --paper: #fffdf8;
  --line: #d8d2c5;
  --line-strong: #b8b4a9;
  --success: #386b5b;
  --warning: #8c5b1c;
  --danger: #9b423d;
  --shadow: 0 20px 50px rgba(22, 44, 52, 0.08);
  --radius: 18px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--cream);
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", YuGothic, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.7;
  overflow-x: hidden;
}

img { display: block; max-width: 100%; }

a { color: inherit; }

button, input, select, textarea { font: inherit; }

button, .button { cursor: pointer; }

button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 3px solid #d28b56;
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: 10;
  top: 0;
  left: 1rem;
  padding: .45rem .8rem;
  color: var(--paper);
  background: var(--blue-deep);
  transform: translateY(-150%);
}

.skip-link:focus { transform: translateY(0); }

.site-header {
  border-bottom: 1px solid rgba(19, 47, 66, .11);
  background: rgba(248, 244, 235, .94);
}

.header-inner, main, .site-footer {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 76px;
  gap: 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .75rem;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  color: var(--paper);
  background: var(--blue-deep);
  border-radius: 50% 50% 44% 56%;
  font-family: Georgia, serif;
  font-size: 1.05rem;
}

.brand strong, .brand small { display: block; line-height: 1.2; }
.brand strong { font-size: .98rem; letter-spacing: .07em; }
.brand small { margin-top: .25rem; color: var(--ink-soft); font-size: .7rem; letter-spacing: .06em; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: .6rem 1.1rem;
  border: 1px solid transparent;
  border-radius: 999px;
  font-weight: 700;
  line-height: 1.3;
  text-decoration: none;
  transition: transform .18s ease, box-shadow .18s ease, background-color .18s ease;
}

.button:hover { transform: translateY(-1px); }
.button-primary { color: var(--paper); background: var(--tea-dark); box-shadow: 0 8px 18px rgba(128, 70, 47, .2); }
.button-primary:hover { background: #6f3928; }
.button-secondary { color: var(--blue-deep); background: var(--blue-light); border-color: #b9d0d2; }
.button-quiet { color: var(--ink); background: transparent; border-color: var(--line-strong); }
.button-quiet:hover { background: rgba(255, 253, 248, .65); }
.button-danger { color: var(--danger); background: #fff7f5; border-color: #d9aaa3; }
.button-danger:hover, .button-danger.is-armed { color: #fff; background: var(--danger); }
.button-small { min-height: 44px; padding: .42rem .82rem; font-size: .88rem; }

.hero {
  display: grid;
  grid-template-columns: minmax(0, .88fr) minmax(0, 1.12fr);
  align-items: center;
  gap: clamp(2rem, 6vw, 5.5rem);
  min-height: 560px;
  padding: 70px 0 82px;
}

.eyebrow {
  margin: 0 0 .7rem;
  color: var(--tea-dark);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .16em;
}

h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { line-height: 1.2; }
h1, h2 { font-family: Georgia, "Hiragino Mincho ProN", serif; font-weight: 500; }
h1 { max-width: 12em; margin-bottom: 1.2rem; color: var(--blue-deep); font-size: clamp(2.7rem, 6vw, 5.2rem); letter-spacing: -.055em; }
h1 em { color: var(--tea); font-style: normal; }
h2 { margin-bottom: .8rem; font-size: clamp(2rem, 4vw, 3.2rem); letter-spacing: -.04em; }
h3 { margin-bottom: .55rem; font-size: 1.15rem; }

.hero-lead { max-width: 34rem; margin-bottom: 1.4rem; color: var(--ink-soft); font-size: 1.06rem; }
.example-note { display: flex; flex-wrap: wrap; align-items: baseline; gap: .45rem .8rem; max-width: 34rem; padding: .75rem .9rem; color: var(--ink); background: rgba(255, 253, 248, .7); border-left: 3px solid var(--tea); font-size: .9rem; }
.example-label { color: var(--tea-dark); font-size: .72rem; font-weight: 800; letter-spacing: .1em; }
.hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; margin-top: 2rem; }
.text-link { color: var(--blue-deep); font-weight: 700; text-underline-offset: .25em; }
.text-link span { display: inline-block; margin-left: .25rem; color: var(--tea); }

.hero-visual { position: relative; margin: 0; }
.hero-visual picture { display: block; overflow: hidden; border-radius: 48% 20px 20px 20px; box-shadow: var(--shadow); background: var(--blue-light); }
.hero-visual img { width: 100%; aspect-ratio: 1870 / 841; object-fit: cover; }
.hero-visual figcaption { margin: .7rem .35rem 0; color: var(--ink-soft); font-size: .76rem; text-align: right; }

.status-message {
  min-height: 2.35rem;
  margin: 0 0 1.25rem;
  padding: .55rem .85rem;
  color: var(--success);
  background: rgba(220, 232, 234, .45);
  border-left: 3px solid var(--success);
  font-size: .9rem;
}
.status-message:empty { visibility: hidden; }
.status-message[data-tone="warning"] { color: var(--warning); background: #fff5de; border-color: #d19a41; }
.status-message[data-tone="error"] { color: var(--danger); background: #fff1ef; border-color: var(--danger); }

.section-layout {
  display: grid;
  grid-template-columns: minmax(210px, .34fr) minmax(0, 1fr);
  gap: clamp(2rem, 6vw, 5.5rem);
  padding: 80px 0;
  border-top: 1px solid var(--line);
}

.section-intro > p:not(.eyebrow) { max-width: 27rem; color: var(--ink-soft); }
.small-note { max-width: 27rem; margin-top: 2rem; padding: 1rem; color: var(--ink-soft); background: var(--tea-pale); border-radius: 3px 14px 14px 14px; font-size: .86rem; }
.small-note strong { display: block; margin-bottom: .25rem; color: var(--tea-dark); }
.small-note p { margin-bottom: 0; }

.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 10px 26px rgba(20, 41, 48, .04); }
.form-panel { padding: clamp(1.25rem, 4vw, 2.2rem); }
.panel-lead { margin-bottom: 1.4rem; color: var(--ink-soft); font-size: .9rem; }

.field-group { min-width: 0; margin-bottom: 1.1rem; }
.field-group label, .reflection-toolbar label { display: flex; align-items: center; gap: .45rem; margin-bottom: .4rem; font-weight: 700; }
.required, .optional { color: var(--tea-dark); font-size: .7rem; font-weight: 700; letter-spacing: .04em; }
.optional { color: var(--ink-soft); font-weight: 500; }
input, select, textarea { width: 100%; min-height: 48px; padding: .7rem .8rem; color: var(--ink); background: #fffefa; border: 1px solid var(--line-strong); border-radius: 8px; font-size: 16px; }
textarea { min-height: 110px; resize: vertical; }
input::placeholder, textarea::placeholder { color: #849097; }
input:focus, select:focus, textarea:focus { border-color: var(--blue-deep); }
.field-help { margin: .35rem 0 0; color: var(--ink-soft); font-size: .76rem; line-height: 1.4; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.form-actions, .button-row { display: flex; flex-wrap: wrap; align-items: center; gap: .7rem; }
.form-actions { margin-top: 1.5rem; }
.form-actions .button-primary { min-width: 12rem; }
.form-errors { margin: 1rem 0; padding: .8rem 1rem; color: var(--danger); background: #fff1ef; border: 1px solid #e3b6af; border-radius: 8px; }
.form-errors ul { margin: 0; padding-left: 1.2rem; }

.preview-panel { margin: 0 0 80px; padding: clamp(1.25rem, 4vw, 2.2rem); border-color: #c8d9d6; background: #f7fbf7; }
.preview-heading { display: flex; justify-content: space-between; gap: 1rem; }
.preview-heading h2 { margin-bottom: 0; font-size: clamp(1.65rem, 3vw, 2.4rem); }
.preview-mark { color: var(--success); font-family: Georgia, serif; font-size: 3rem; line-height: 1; }
.preview-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, .65fr); gap: 1rem 2rem; align-items: start; margin: 1.6rem 0; padding-top: 1.2rem; border-top: 1px solid #c8d9d6; }
.preview-body h3 { margin-bottom: .25rem; font-size: 1.35rem; }
.preview-summary { color: var(--success); font-weight: 800; }
.preview-detail { display: grid; grid-template-columns: auto 1fr; gap: .35rem .8rem; margin: 0; font-size: .9rem; }
.preview-detail dt { color: var(--ink-soft); }
.preview-detail dd { margin: 0; font-weight: 700; }

.library-content, .reflection-panel, .backup-panel { min-width: 0; }
.filters { padding: 1.1rem 1.25rem 1.25rem; }
.filter-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: .8rem; }
.filter-heading h3 { margin: 0; }
.count-label { color: var(--ink-soft); font-size: .82rem; }
.filter-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .8rem; }
.filter-grid .field-group { margin: 0; }
.book-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-top: 1.1rem; }
.book-card { display: flex; flex-direction: column; min-width: 0; min-height: 270px; padding: 1.15rem; background: var(--paper); border: 1px solid var(--line); border-radius: 14px; }
.book-card-top { display: flex; align-items: start; justify-content: space-between; gap: .7rem; }
.book-card h3 { margin-bottom: .75rem; overflow-wrap: anywhere; }
.status-badge { flex: 0 0 auto; padding: .25rem .55rem; border-radius: 999px; font-size: .72rem; font-weight: 800; white-space: nowrap; }
.status-badge.is-unread { color: var(--ink-soft); background: #e7e8e5; }
.status-badge.is-reading { color: #795126; background: #f5e4be; }
.status-badge.is-complete { color: #2e6655; background: #dcece2; }
.book-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .7rem; margin-bottom: 1rem; color: var(--ink-soft); font-size: .78rem; }
.tag-list { display: flex; flex-wrap: wrap; gap: .3rem; }
.tag { color: var(--tea-dark); }
.progress-wrap { margin-top: auto; }
.progress-label { display: flex; justify-content: space-between; gap: .7rem; margin-bottom: .4rem; color: var(--ink-soft); font-size: .77rem; }
.progress-label strong { color: var(--ink); text-align: right; }
.progress-bar { height: 8px; overflow: hidden; background: #e3e8e6; border-radius: 999px; }
.progress-fill { display: block; height: 100%; background: var(--tea); border-radius: inherit; }
.progress-note { margin: .1rem 0 0; color: var(--ink-soft); font-size: .76rem; }
.note-details { margin-top: 1rem; color: var(--ink-soft); border-top: 1px solid var(--line); font-size: .84rem; }
.note-details summary { padding-top: .65rem; cursor: pointer; font-weight: 700; }
.note-details p { margin: .45rem 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.card-actions { display: flex; gap: .5rem; margin-top: 1rem; padding-top: .8rem; border-top: 1px solid var(--line); }
.empty-state { grid-column: 1 / -1; padding: 2.2rem 1.2rem; color: var(--ink-soft); background: rgba(255, 253, 248, .55); border: 1px dashed var(--line-strong); border-radius: 14px; text-align: center; }

.reflection-panel { padding: 1.35rem; background: var(--blue-deep); border-color: var(--blue-deep); color: var(--paper); }
.reflection-toolbar { display: flex; align-items: center; gap: 1rem; max-width: 340px; margin-bottom: 1.35rem; }
.reflection-toolbar label { margin: 0; color: #dce8ea; white-space: nowrap; }
.reflection-toolbar input { min-height: 44px; color: var(--paper); background: rgba(255, 255, 255, .1); border-color: rgba(255,255,255,.35); }
.reflection-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; margin-bottom: 1.6rem; }
.stat-card { min-height: 98px; padding: .85rem; background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.16); border-radius: 10px; }
.stat-card span, .stat-card strong { display: block; }
.stat-card span { color: #c5d9dc; font-size: .75rem; }
.stat-card strong { margin-top: .35rem; font-family: Georgia, serif; font-size: 1.6rem; font-weight: 500; }
.stat-note { background: rgba(216, 165, 96, .15); }
.reflection-panel h3 { margin-bottom: .7rem; font-family: Georgia, serif; font-size: 1.3rem; font-weight: 500; }
.reflection-books { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .45rem 1rem; margin: 0; padding: 0; list-style: none; }
.reflection-books li { display: flex; justify-content: space-between; gap: .6rem; padding: .55rem 0; border-bottom: 1px solid rgba(255,255,255,.15); font-size: .84rem; }
.reflection-books li span { color: #c5d9dc; white-space: nowrap; }
.reflection-panel .muted { margin-bottom: 0; color: #c5d9dc; font-size: .88rem; }

.backup-panel { padding: 0; overflow: hidden; }
.backup-actions, .danger-zone { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; padding: 1.35rem; }
.backup-actions h3, .danger-zone h3 { margin-bottom: .25rem; }
.backup-actions p, .danger-zone p { margin: 0; color: var(--ink-soft); font-size: .84rem; }
.danger-zone { border-top: 1px solid var(--line); background: #fff9f7; }
.file-button { position: relative; overflow: hidden; }
.file-button:focus-within { outline: 3px solid #d28b56; outline-offset: 3px; }
.file-button input { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 100%; padding: 0; opacity: 0; cursor: pointer; }

.site-footer { display: flex; align-items: end; justify-content: space-between; gap: 1.5rem; padding: 40px 0 60px; border-top: 1px solid var(--line); color: var(--ink-soft); font-size: .8rem; }
.site-footer strong { color: var(--ink); }
.site-footer p { margin: .3rem 0 0; }
.footer-meta { text-align: right; }
.footer-meta span { color: var(--tea-dark); }
.noscript-message { padding: 1rem; color: var(--danger); background: #fff1ef; text-align: center; }

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; min-height: 0; padding: 54px 0 66px; }
  .hero-copy { max-width: 680px; }
  .hero-visual { max-width: 700px; }
  .section-layout { grid-template-columns: 1fr; gap: 1.5rem; padding: 64px 0; }
  .section-intro > p:not(.eyebrow), .small-note { max-width: 48rem; }
  .small-note { margin-top: 1.1rem; }
}

@media (max-width: 620px) {
  .header-inner, main, .site-footer { width: min(calc(100% - 28px), 1180px); }
  .header-inner { min-height: 68px; }
  .header-print { min-height: 44px; padding-inline: .75rem; font-size: .83rem; }
  .hero { padding: 44px 0 50px; }
  h1 { font-size: clamp(2.5rem, 14vw, 4rem); }
  .hero-lead { font-size: 1rem; }
  .hero-visual figcaption { text-align: left; }
  .section-layout { padding: 52px 0; }
  .field-grid, .filter-grid, .book-grid, .reflection-books { grid-template-columns: 1fr; }
  .preview-body { grid-template-columns: 1fr; }
  .reflection-stats { grid-template-columns: 1fr; }
  .stat-card { min-height: 0; }
  .backup-actions, .danger-zone, .site-footer { align-items: start; flex-direction: column; }
  .footer-meta { text-align: left; }
  .form-actions .button-primary { min-width: 0; }
  .status-message { font-size: .82rem; }
}

@media (max-width: 360px) {
  .header-inner, main, .site-footer { width: calc(100% - 22px); }
  .brand strong { font-size: .88rem; }
  .brand small { font-size: .62rem; }
  .brand-mark { width: 34px; height: 34px; }
  .hero-actions, .form-actions, .button-row { align-items: stretch; flex-direction: column; }
  .hero-actions .button, .form-actions .button, .button-row .button { width: 100%; }
  .reflection-toolbar { align-items: stretch; flex-direction: column; gap: .45rem; }
  .reflection-toolbar input { width: 100%; }
  .backup-actions, .danger-zone { padding: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

@media print {
  body { background: #fff; color: #000; }
  .site-header, .hero, .status-message, .form-layout, .preview-panel, .backup-layout, .filters, .card-actions, .skip-link, .site-footer { display: none !important; }
  main { width: 100%; }
  .section-layout { display: block; padding: 1rem 0; border: 0; }
  .section-intro { display: none; }
  .book-grid { grid-template-columns: repeat(2, 1fr); margin-top: 0; }
  .book-card, .reflection-panel { break-inside: avoid; box-shadow: none; }
  .reflection-panel { color: #000; background: #fff; border: 1px solid #aaa; }
  .reflection-toolbar { display: none; }
  .stat-card { color: #000; background: #fff; border-color: #aaa; }
  .stat-card span, .reflection-books li span { color: #333; }
}
