:root {
  color-scheme: light;
  --paper: #f5f0e6;
  --paper-deep: #e9dfce;
  --ink: #24211d;
  --muted: #756d62;
  --line: #d6cab8;
  --accent: #d45535;
  --accent-dark: #a83c23;
  --green: #486a55;
  --shadow: 0 18px 45px rgba(61, 45, 24, .09);
}

* { box-sizing: border-box; }
html { background: var(--paper); }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 0%, rgba(255,255,255,.85), transparent 28rem),
    var(--paper);
  font-family: "Yu Gothic UI", "Hiragino Kaku Gothic ProN", system-ui, sans-serif;
  line-height: 1.65;
}
a { color: inherit; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
.site-header {
  position: sticky; top: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center;
  gap: 1rem; padding: .8rem max(1rem, calc((100vw - 1080px) / 2));
  background: rgba(245,240,230,.92); border-bottom: 1px solid rgba(117,109,98,.2);
  backdrop-filter: blur(16px);
}
.brand { text-decoration: none; font-family: Georgia, serif; font-size: 1.2rem; font-weight: 700; white-space: nowrap; }
.brand span { color: var(--accent); font-style: italic; }
nav { display: flex; gap: .2rem; overflow-x: auto; }
nav a { padding: .5rem .65rem; border-radius: 999px; text-decoration: none; font-size: .84rem; }
nav a:hover { background: var(--paper-deep); }
main { min-height: calc(100vh - 64px); }
.section, .capture-hero { width: min(1080px, calc(100% - 2rem)); margin: 0 auto; }
.capture-hero { padding: clamp(3rem, 8vw, 6.5rem) 0 4rem; text-align: center; }
.capture-hero h1, .page-head h1, .detail h1, .login-card h1 {
  margin: .1em 0; font: 700 clamp(2.25rem, 7vw, 5.2rem)/1.04 Georgia, "Yu Mincho", serif;
  letter-spacing: -.035em;
}
.eyebrow { margin: 0; color: var(--accent-dark); font-size: .72rem; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; }
.lead { color: var(--muted); margin: .6rem 0 2rem; }
.capture-grid { display: grid; grid-template-columns: .78fr 1.22fr; gap: 1rem; margin-top: 2rem; text-align: left; }
.record-panel, .text-panel, .login-card, .item-card {
  border: 1px solid var(--line); border-radius: 22px; background: rgba(255,255,255,.42); box-shadow: var(--shadow);
}
.record-panel { display: grid; place-items: center; align-content: center; min-height: 300px; padding: 2rem; text-align: center; }
.text-panel { display: flex; flex-direction: column; padding: 1.5rem; }
label { display: grid; gap: .38rem; color: var(--muted); font-size: .82rem; font-weight: 700; }
input, textarea, select {
  width: 100%; border: 1px solid var(--line); border-radius: 11px; padding: .8rem .9rem;
  color: var(--ink); background: rgba(255,255,255,.68); outline: none;
}
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(212,85,53,.13); }
.record-button {
  display: grid; place-items: center; gap: .7rem; width: 168px; aspect-ratio: 1;
  border: 0; border-radius: 50%; color: white; background: var(--ink); box-shadow: 0 14px 28px rgba(36,33,29,.22);
  transition: transform .15s, background .15s;
}
.record-button:hover { transform: translateY(-2px); }
.record-button.recording { background: var(--accent); animation: pulse 1.8s infinite; }
.record-dot { width: 25px; height: 25px; background: var(--accent); border-radius: 50%; }
.recording .record-dot { background: white; border-radius: 5px; }
@keyframes pulse { 50% { box-shadow: 0 0 0 15px rgba(212,85,53,.12); } }
.inline-fields, .actions, .section-heading, .detail-head { display: flex; align-items: end; justify-content: space-between; gap: 1rem; }
.inline-fields { margin-top: 1rem; }
.inline-fields label { flex: 1; }
.primary, .secondary, .quiet {
  border-radius: 999px; padding: .72rem 1.2rem; font-weight: 800; border: 1px solid transparent; white-space: nowrap;
}
.primary { background: var(--accent); color: white; }
.primary:hover { background: var(--accent-dark); }
.secondary { border-color: var(--ink); background: transparent; color: var(--ink); }
.quiet { background: transparent; color: var(--muted); }
.muted, .hint { color: var(--muted); font-weight: 400; }
.notice { max-width: 680px; margin: 1.2rem auto 0; padding: .85rem 1rem; border: 1px solid #b8c8bb; border-radius: 10px; color: var(--green); background: #edf3ed; text-align: left; }
.notice.error, .error { color: #9d2c25; background: #fae9e6; border-color: #e3b8b1; }
.system-banner {
  display: flex; justify-content: space-between; gap: 1rem; margin: 0 auto 2rem; padding: .8rem 1rem;
  border: 1px solid #d7a59a; border-radius: 12px; color: #7f291f; background: #fae9e6;
  text-align: left; text-decoration: none;
}
.system-banner span { color: #8f5148; }
.system-banner-warning { color: #6e521d; background: #faf1d8; border-color: #dbc585; }
.hidden { display: none !important; }
.recent { padding-bottom: 5rem; }
.section-heading { margin-bottom: 1rem; }
.section-heading h2 { margin: 0; font: 700 2rem Georgia, serif; }
.section-heading a { color: var(--accent-dark); font-weight: 700; text-decoration: none; }
.review-list { border-top: 1px solid var(--line); }
.review-row { display: grid; grid-template-columns: 1fr auto; gap: 1rem; padding: 1rem .25rem; border-bottom: 1px solid var(--line); text-decoration: none; }
.review-row:hover strong { color: var(--accent-dark); }
.review-row p { max-width: 720px; margin: .2rem 0; color: var(--muted); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.row-meta { display: flex; flex-direction: column; align-items: end; gap: .35rem; color: var(--muted); font-size: .76rem; }
.status { border: 1px solid var(--line); border-radius: 999px; padding: .1rem .5rem; }
.status-ready { color: var(--green); border-color: #9db5a2; }
.status-failed, .status-needs_review { color: var(--accent-dark); border-color: #d7a59a; }
.rating { color: var(--accent-dark); font: 700 1.5rem Georgia, serif; }
.rating small, .score small { color: var(--muted); font-size: .48em; }
.tags { display: flex; flex-wrap: wrap; gap: .35rem; color: var(--green); font-size: .76rem; }
.page-head, .detail { padding: clamp(2.5rem, 6vw, 5rem) 0 6rem; }
.filters { display: grid; grid-template-columns: 2fr repeat(3, 1fr) auto auto; gap: .6rem; margin: 2rem 0; }
.detail { max-width: 850px; }
.detail-head { align-items: flex-start; border-bottom: 1px solid var(--line); padding-bottom: 1.5rem; }
.detail-head h1 { font-size: clamp(2rem, 6vw, 4rem); }
.detail-head p { color: var(--muted); }
.score { min-width: 112px; color: var(--accent); font: 700 4rem/1 Georgia, serif; text-align: right; }
.summary { margin: 2rem 0; font: 500 1.22rem/1.7 Georgia, "Yu Mincho", serif; }
audio { width: 100%; margin: 0 0 1.5rem; }
.edit-form { display: grid; gap: 1rem; margin: 2rem 0; padding: 1.4rem; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.35); }
.form-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 2fr; gap: .8rem; }
.detail section { margin-top: 2.5rem; }
.detail h2 { font: 700 1.5rem Georgia, serif; }
.raw-text { padding: 1rem; white-space: pre-wrap; border-radius: 10px; background: var(--paper-deep); font: inherit; }
.item-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.item-card { display: block; padding: 1.25rem; text-decoration: none; }
.item-card:hover { border-color: var(--accent); }
.item-card h2 { margin: .3rem 0; font: 700 1.35rem Georgia, "Yu Mincho", serif; }
.item-card p { color: var(--muted); }
.empty { padding: 2rem 0; color: var(--muted); }
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card { width: min(480px, 100%); padding: clamp(1.6rem, 7vw, 3rem); }
.login-card h1 { font-size: clamp(2.2rem, 10vw, 4.2rem); margin-bottom: 2rem; }
.login-card form { display: grid; gap: 1rem; }
.system-page { max-width: 900px; }
.overall-state {
  display: flex; align-items: center; gap: 1rem; margin: 2rem 0 1rem; padding: 1rem 1.2rem;
  border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.42);
}
.overall-state p { margin: .1rem 0 0; color: var(--muted); font-size: .82rem; }
.health-dot { display: inline-block; width: .72rem; height: .72rem; flex: 0 0 auto; border-radius: 50%; background: #9a9389; }
.overall-ok .health-dot, .health-ok .health-dot { background: #4f8a60; box-shadow: 0 0 0 4px rgba(79,138,96,.12); }
.overall-warning .health-dot { background: #bd8b25; box-shadow: 0 0 0 4px rgba(189,139,37,.12); }
.overall-error .health-dot, .health-error .health-dot { background: #c84c3c; box-shadow: 0 0 0 4px rgba(200,76,60,.12); }
.health-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem; }
.health-card { padding: 1rem; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.32); }
.health-heading { display: flex; align-items: center; gap: .6rem; }
.health-card p { margin: .6rem 0; color: var(--muted); font-size: .9rem; }
.health-card small { color: var(--muted); overflow-wrap: anywhere; }
.status-help { margin: 1rem 0; padding: 1rem 1.2rem; border-left: 4px solid var(--accent); background: rgba(255,255,255,.38); }
.status-help p { margin: .4rem 0 0; }
code { padding: .1rem .3rem; border-radius: 5px; background: var(--paper-deep); overflow-wrap: anywhere; }
.status-section { margin-top: 2.5rem; }
.status-section h2 { margin-bottom: .8rem; font: 700 1.5rem Georgia, "Yu Mincho", serif; }
.count-grid { display: grid; grid-template-columns: repeat(5, 1fr); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.count-grid div { display: grid; gap: .15rem; padding: .9rem; border-right: 1px solid var(--line); text-align: center; }
.count-grid div:last-child { border-right: 0; }
.count-grid strong { font: 700 1.6rem Georgia, serif; }
.count-grid span { color: var(--muted); font-size: .78rem; }
.failure-list { border-top: 1px solid var(--line); }
.failure-list a { display: grid; gap: .25rem; padding: .9rem .2rem; border-bottom: 1px solid var(--line); text-decoration: none; }
.failure-list span, .failure-list code, .import-state p { color: var(--muted); font-size: .8rem; }
.failure-list code { color: #8d3228; }
.import-state { padding: 1rem; border: 1px solid var(--line); border-radius: 14px; }
.import-state p { margin: .6rem 0; }

@media (max-width: 760px) {
  .site-header { align-items: flex-start; flex-direction: column; padding-bottom: .45rem; }
  nav { width: 100%; justify-content: space-between; }
  .capture-grid { grid-template-columns: 1fr; }
  .record-panel { min-height: 250px; }
  .filters, .form-grid { grid-template-columns: 1fr; }
  .item-grid { grid-template-columns: 1fr; }
  .review-row { grid-template-columns: 1fr; }
  .row-meta { align-items: flex-start; flex-direction: row; flex-wrap: wrap; }
  .detail-head { align-items: flex-start; }
  .score { min-width: 70px; font-size: 3rem; }
  .actions { align-items: stretch; flex-direction: column; }
  .system-banner { flex-direction: column; gap: .2rem; }
  .health-grid { grid-template-columns: 1fr; }
  .count-grid { grid-template-columns: repeat(5, minmax(58px, 1fr)); overflow-x: auto; }
  .count-grid div { padding: .7rem .4rem; }
}
