:root {
  --cream: #fff9eb;
  --paper: #f9edda;
  --cocoa: #4b2b1b;
  --muted: #8a6d59;
  --coral: #af4437;
  --honey: #efbd62;
  --teal: #2b7c73;
  --line: rgba(114, 75, 49, .2);
  font-family: "Yu Gothic UI", "Hiragino Maru Gothic ProN", system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: #d8cdbd; }
body { margin: 0; color: var(--cocoa); background: radial-gradient(circle at 15% 5%, #fff6e8, #d5c7b5 72%); }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }

.app-shell { width: min(100%, 480px); height: 100dvh; margin: 0 auto; overflow: hidden; background: var(--cream); box-shadow: 0 0 48px rgba(70, 43, 25, .22); }
.view { display: none; height: 100%; padding: max(14px, env(safe-area-inset-top)) 14px max(8px, env(safe-area-inset-bottom)); background: radial-gradient(circle, rgba(176,67,54,.08) 1.5px, transparent 1.8px) 0 0/28px 28px, linear-gradient(rgba(255,255,255,.6), rgba(255,248,233,.78)), var(--cream); }
.view.is-active { display: flex; }
.cute-view { flex-direction: column; min-height: 0; }
.view-content { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; padding: 0 3px 10px; }

.topbar { min-height: 58px; display: flex; align-items: center; justify-content: center; position: relative; margin: 0 3px 12px; padding: 8px 68px; border: 2px solid #c99d6e; border-radius: 14px; background: rgba(255,253,246,.92); box-shadow: inset 0 0 0 4px #f7e6c8, 0 4px 12px rgba(89,50,27,.06); }
.topbar::before, .topbar::after { content: "❧"; position: absolute; color: var(--coral); font-size: 1.25rem; }
.topbar::before { left: 14px; }
.topbar::after { right: 14px; transform: scaleX(-1); }
.topbar h1 { margin: 0; font: 700 1.34rem/1.2 Georgia, "Yu Mincho", serif; letter-spacing: .08em; white-space: nowrap; }
.heading-berries { display: none; }
.view-nav { display: flex; justify-content: flex-end; margin: -5px 5px 7px; }
.text-button { position: static; border: 0; border-bottom: 1px solid var(--line); padding: 5px 2px; color: var(--cocoa); background: transparent; font-size: .75rem; white-space: nowrap; }
.back-button { position: absolute; left: 14px; z-index: 2; border: 0; color: var(--cocoa); background: transparent; font: 2rem/1 Georgia, serif; }

.timer-stage { padding-top: 3px; }
.timer-ring { width: min(68.4vw, 288px); aspect-ratio: 1; margin: 0 auto 10px; display: grid; place-content: center; text-align: center; border: 9px double #755038; outline: 4px dotted #9b765b; outline-offset: -2px; border-radius: 50%; background: radial-gradient(circle, #fffdf5 58%, #f4dfbc 100%); box-shadow: 0 8px 22px rgba(91,54,30,.12); }
.timer-ring span { color: var(--muted); font-size: .72rem; letter-spacing: .12em; }
#timer-display { margin: 8px 0; font: 500 clamp(3.1rem, 15vw, 4.55rem)/1 Georgia, serif; letter-spacing: -.045em; font-variant-numeric: tabular-nums; }
.timer-ring b { color: var(--coral); letter-spacing: .09em; }
.timer-controls { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1.45fr); gap: 8px; margin-bottom: 10px; }
.button { min-width: 0; min-height: 48px; border: 0; border-radius: 999px; padding: 10px 12px; font-weight: 700; letter-spacing: .04em; }
.button-honey { color: var(--cocoa); border: 2px solid #a87630; background: linear-gradient(#ffe6a8,#eeb95e); box-shadow: inset 0 0 0 3px rgba(255,255,255,.42); }
.button-coral { color: #fffaf0; border: 2px solid #7d2e28; background: linear-gradient(#c95a4a,#a83b31); box-shadow: inset 0 0 0 3px rgba(255,255,255,.14); }
.button-copper { color: #fffaf0; border: 2px solid #7d2e28; background: linear-gradient(#c95a4a,#a83b31); }
.button-outline-light { color: var(--cocoa); border: 1px solid #c9a780; background: rgba(255,253,246,.82); }
.event-card, .summary-card, .field, .history-card, .dark-summary { border: 1px solid #d9b98f; border-radius: 13px; background: rgba(255,253,246,.9); box-shadow: 0 5px 14px rgba(84,51,28,.06); }
.event-row { width: 100%; min-height: 49px; display: flex; align-items: center; justify-content: space-between; gap: 10px; border: 0; border-bottom: 1px dashed #ddc6a8; padding: 0 15px; color: var(--cocoa); background: transparent; text-align: left; }
.event-row:last-child { border: 0; }
.event-row strong { color: var(--muted); font-size: .78rem; white-space: nowrap; }
.event-row.is-recorded strong { color: var(--coral); }
.quiet-button, .danger-button, .delete-all-button { display: block; margin: 12px auto 0; border: 0; color: #9c493e; background: transparent; text-decoration: underline; text-underline-offset: 4px; font-size: .8rem; }

.form-stack, .detail-stack { display: grid; gap: 11px; }
.summary-card { overflow: hidden; }
.summary-card div, .dark-summary div { min-height: 43px; display: flex; align-items: center; justify-content: space-between; padding: 0 15px; border-bottom: 1px solid var(--line); }
.summary-card div:last-child, .dark-summary div:last-child { border: 0; }
.summary-card strong, .dark-summary strong { font-family: Georgia, serif; font-variant-numeric: tabular-nums; }
.berry-divider { text-align: center; color: var(--coral); letter-spacing: .45em; }
.field { display: grid; gap: 7px; padding: 11px; font-weight: 700; }
.field input, .field textarea { width: 100%; border: 1px solid #d4b68f; border-radius: 9px; padding: 11px 12px; color: var(--cocoa); background: rgba(255,255,255,.64); outline: none; resize: vertical; }
.field input:focus, .field textarea:focus { border-color: var(--coral); box-shadow: 0 0 0 3px rgba(175,68,55,.1); }
.field small { color: var(--muted); font-size: .72rem; font-weight: 400; }

.history-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 20px 2px 12px; }
.history-actions p { margin: 0; color: var(--muted); font-size: .82rem; }
.outline-button { min-height: 40px; border: 1px solid #c9a780; border-radius: 9px; padding: 7px 10px; color: var(--cocoa); background: rgba(255,253,246,.82); font-size: .72rem; }
.history-list { display: grid; gap: 10px; }
.history-card { width: 100%; display: grid; gap: 6px; padding: 16px; color: var(--cocoa); text-align: left; }
.history-date, .history-meta { color: var(--muted); font-size: .75rem; }
.history-note { overflow: hidden; font-size: .82rem; white-space: nowrap; text-overflow: ellipsis; }
.empty-state { padding: 40px 8px; text-align: center; color: var(--muted); }
.delete-all-section { margin-top: 28px; padding: 20px 0; border-top: 1px solid var(--line); }
.detail-heading span { color: var(--muted); font-size: .75rem; }
.detail-heading h2 { margin: 5px 0 0; }

.character-stage { position: relative; flex: 0 0 clamp(142px, 21dvh, 178px); display: flex; align-items: flex-end; justify-content: space-around; gap: 4px; overflow: hidden; margin: 0 -2px; padding: 24px 4px 0; border-top: 2px solid rgba(199,155,104,.32); border-radius: 28px 28px 10px 10px; background: radial-gradient(circle, rgba(175,68,55,.09) 1.4px, transparent 1.7px) 0 0/34px 34px, linear-gradient(180deg, rgba(255,250,237,.58), #fff5e2); box-shadow: 0 -8px 20px rgba(99,62,34,.04); isolation: isolate; }
.stage-ornament { position: absolute; left: 50%; bottom: 20px; z-index: 0; transform: translateX(-50%); color: rgba(120,73,43,.3); font-size: 1.8rem; }
.character { position: relative; z-index: 1; width: 46%; height: 100%; overflow: hidden; border: 0; padding: 0; background: transparent; mix-blend-mode: multiply; -webkit-tap-highlight-color: transparent; }
.character img { width: 100%; height: 100%; display: block; object-fit: contain; object-position: center bottom; pointer-events: none; }
.character-acrobat img { transform: scale(1.05); }
.character.is-talking { animation: character-wiggle .48s ease-in-out; }
@keyframes character-wiggle { 0%,100%{transform:rotate(0)} 20%{transform:rotate(-4deg) translateY(-3px)} 45%{transform:rotate(4deg)} 70%{transform:rotate(-2deg) translateY(-1px)} }
.speech-bubble { position: absolute; z-index: 4; top: 4px; left: 50%; max-width: 88%; padding: 7px 12px; border: 1px solid #b88a62; border-radius: 14px; color: var(--cocoa); background: #fffdf5; box-shadow: 0 4px 12px rgba(69,42,24,.12); font-size: .76rem; font-weight: 700; white-space: nowrap; opacity: 0; transform: translate(-50%,6px); transition: .18s ease; pointer-events: none; }
.speech-bubble.is-visible { opacity: 1; transform: translate(-50%,0); }

.confirm-dialog { width: min(calc(100% - 40px),410px); padding: 0; border: 0; border-radius: 18px; color: var(--cocoa); background: var(--cream); box-shadow: 0 24px 80px rgba(0,0,0,.35); }
.confirm-dialog::backdrop { background: rgba(53,31,18,.68); backdrop-filter: blur(3px); }
.confirm-dialog form { padding: 26px 22px 22px; }
.confirm-dialog h2 { margin: 8px 0; font-size: 1.15rem; }
.confirm-dialog p { color: var(--muted); line-height: 1.6; }
.dialog-kicker { color: var(--coral) !important; font-weight: 700; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: 8px; margin-top: 20px; }
.dialog-cancel { border: 1px solid #c8aa87; background: transparent; }
.dialog-delete { color: white; background: var(--coral); }
.toast { position: fixed; z-index: 10; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); transform: translate(-50%,12px); width: max-content; max-width: calc(100% - 32px); padding: 10px 15px; border-radius: 999px; color: white; background: rgba(75,43,27,.94); opacity: 0; pointer-events: none; transition: .2s ease; }
.toast.is-visible { opacity: 1; transform: translate(-50%,0); }

@media (min-width: 700px) { body { padding: 22px 0; } .app-shell { height: calc(100dvh - 44px); border-radius: 30px; } }
@media (max-height: 720px) { .character-stage { flex-basis: 126px; } .timer-ring { width: 220px; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } .character.is-talking { animation: none; } }
