*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f5f5f5;
  --card: #ffffff;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --danger: #dc2626;
  --success: #16a34a;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --radius: 12px;
}

body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; }

.card { background: var(--card); border-radius: var(--radius); padding: 2rem; width: 100%; max-width: 480px; box-shadow: 0 4px 24px rgba(0,0,0,.08); }

h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: .25rem; }
h2 { font-size: 1.2rem; font-weight: 600; margin-bottom: 1rem; }
p.sub { color: var(--muted); font-size: .9rem; margin-bottom: 1.5rem; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .6rem 1.2rem; border: none; border-radius: 8px; cursor: pointer; font-size: .95rem; font-weight: 600; transition: background .15s; width: 100%; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger  { background: var(--danger);  color: #fff; }
.btn-outline { background: transparent; border: 2px solid var(--border); color: var(--text); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

input[type=text] { width: 100%; padding: .6rem .9rem; border: 1.5px solid var(--border); border-radius: 8px; font-size: 1rem; outline: none; transition: border .15s; }
input[type=text]:focus { border-color: var(--primary); }

.field { margin-bottom: 1rem; }
label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: .3rem; color: var(--muted); }

/* Progress bar */
.progress-wrap { background: var(--border); border-radius: 99px; height: 6px; margin: 1rem 0; }
.progress-bar  { background: var(--primary); height: 6px; border-radius: 99px; transition: width .3s; }

/* Phrase box */
.phrase-box { background: #eef2ff; border-left: 4px solid var(--primary); padding: .9rem 1rem; border-radius: 8px; font-size: 1.05rem; font-weight: 500; margin: 1rem 0; }

/* Recording indicator */
.recorder { text-align: center; margin: 1.2rem 0; }
.rec-circle { width: 64px; height: 64px; border-radius: 50%; background: var(--primary); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; transition: transform .15s; }
.rec-circle:hover { transform: scale(1.08); }
.rec-circle.recording { background: var(--danger); animation: pulse 1s ease-in-out infinite; }
.rec-circle svg { width: 28px; height: 28px; fill: #fff; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(220,38,38,.4); } 50% { box-shadow: 0 0 0 12px rgba(220,38,38,0); } }
.rec-label { font-size: .85rem; color: var(--muted); margin-top: .4rem; }

/* Volume bar */
.vol-bar-wrap { height: 4px; background: var(--border); border-radius: 99px; margin-top: .6rem; }
.vol-bar { height: 4px; background: var(--primary); border-radius: 99px; transition: width .05s; }

/* Result */
.result { text-align: center; padding: 1rem 0; }
.result .icon { font-size: 2.5rem; }
.result h2 { margin: .5rem 0 .25rem; }
.result .detail { font-size: .85rem; color: var(--muted); margin-bottom: 1rem; }
.result .scores { display: flex; justify-content: center; gap: 1.5rem; margin: .75rem 0; }
.result .score-item { text-align: center; }
.result .score-val { font-size: 1.3rem; font-weight: 700; }
.result .score-lbl { font-size: .75rem; color: var(--muted); }

/* Diary list */
.diary-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.entry-list { list-style: none; }
.entry-item { display: flex; align-items: center; gap: .75rem; padding: .75rem 0; border-bottom: 1px solid var(--border); }
.entry-item:last-child { border-bottom: none; }
.entry-info { flex: 1; font-size: .9rem; }
.entry-info .date { color: var(--muted); font-size: .8rem; }
.entry-actions { display: flex; gap: .4rem; }
.entry-actions button { padding: .3rem .6rem; font-size: .8rem; width: auto; }
.empty-state { text-align: center; color: var(--muted); padding: 2rem 0; }

.alert { padding: .75rem 1rem; border-radius: 8px; font-size: .9rem; margin-bottom: 1rem; }
.alert-error   { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: var(--success); border: 1px solid #bbf7d0; }

.mt1 { margin-top: .75rem; }
.mt2 { margin-top: 1.5rem; }
.gap1 { display: flex; flex-direction: column; gap: .6rem; }
.text-center { text-align: center; }
.text-muted { color: var(--muted); font-size: .85rem; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
