*{margin:0;padding:0;box-sizing:border-box;-webkit-tap-highlight-color:transparent}

:root{
  --bg:#0c0b10;
  --surface:#14131c;
  --surface-2:#1c1b27;
  --text:#e4e2ec;
  --text-muted:#8a87a0;
  --text-dim:#555370;
  --border:#1e1d2a;
  --accent:#7c6aef;
  --accent-warm:#d4a574;
  --rec:#ef4a5b;
  --rec-glow:#ef4a5b40;
  --success:#5fcf80;
}

html,body{height:100%;overscroll-behavior:none}
body{
  background:var(--bg);
  color:var(--text);
  font-family:'Noto Sans KR','Outfit',sans-serif;
  font-weight:400;
  line-height:1.6;
  -webkit-font-smoothing:antialiased;
  user-select:none;
  -webkit-user-select:none;
}

.app{
  min-height:100dvh;
  max-width:480px;
  margin:0 auto;
  padding:20px;
  display:flex;
  flex-direction:column;
}

.app-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding-bottom:20px;
  border-bottom:1px solid var(--border);
  margin-bottom:32px;
}

.logo{
  display:flex;
  align-items:center;
  gap:10px;
  font-family:'Outfit',sans-serif;
  font-weight:700;
  font-size:16px;
  letter-spacing:-0.02em;
}

.logo .dot{
  width:10px;height:10px;
  background:var(--rec);
  border-radius:50%;
  box-shadow:0 0 12px var(--rec-glow);
}

.back-link{
  font-size:13px;
  color:var(--text-muted);
  text-decoration:none;
  padding:6px 10px;
  border:1px solid var(--border);
  border-radius:6px;
  user-select:none;
}
.back-link:active{background:var(--surface)}

/* RECORDER */
.recorder{
  flex:1;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:24px;
  padding:20px 0;
}

.status{
  font-size:13px;
  font-weight:500;
  color:var(--text-muted);
  letter-spacing:0.05em;
  text-transform:uppercase;
}
.status.recording{
  color:var(--rec);
}
.status.recording::before{
  content:'';
  display:inline-block;
  width:8px;height:8px;
  background:var(--rec);
  border-radius:50%;
  margin-right:6px;
  vertical-align:middle;
  animation:pulse 1.2s infinite;
}

@keyframes pulse{
  0%,100%{opacity:1;transform:scale(1)}
  50%{opacity:0.4;transform:scale(0.85)}
}

.timer{
  font-family:'Outfit',sans-serif;
  font-size:64px;
  font-weight:300;
  letter-spacing:-0.04em;
  color:var(--text);
  font-variant-numeric:tabular-nums;
}

.visualizer{
  width:100%;
  height:80px;
  display:flex;
  align-items:center;
  justify-content:center;
  opacity:0.6;
}
#viz{
  max-width:100%;
}

.rec-btn{
  width:120px;height:120px;
  border-radius:50%;
  border:none;
  background:var(--rec);
  color:white;
  cursor:pointer;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:8px;
  box-shadow:0 8px 32px var(--rec-glow), inset 0 1px 0 rgba(255,255,255,0.2);
  transition:transform 0.15s ease, box-shadow 0.15s ease;
  font-family:inherit;
}
.rec-btn:active{
  transform:scale(0.95);
  box-shadow:0 4px 16px var(--rec-glow), inset 0 1px 0 rgba(255,255,255,0.2);
}
.rec-btn.recording{
  background:var(--surface-2);
  color:var(--text);
  border:2px solid var(--rec);
  box-shadow:0 0 0 6px var(--rec-glow);
}
.rec-btn.recording .rec-icon{
  background:var(--rec);
  border-radius:6px;
  width:24px;height:24px;
}
.rec-icon{
  width:32px;height:32px;
  background:white;
  border-radius:50%;
  transition:all 0.2s ease;
}
.rec-label{
  font-size:13px;
  font-weight:500;
  letter-spacing:0.02em;
}

/* 일시정지/종료 컨트롤 — 녹음 중/일시정지 상태에서 노출 */
.rec-controls{
  display:flex;
  gap:12px;
  width:100%;
  justify-content:center;
}
.ctrl-btn{
  flex:1;
  max-width:160px;
  padding:14px 18px;
  background:var(--surface-2);
  border:1px solid var(--border);
  border-radius:12px;
  color:var(--text);
  font-family:inherit;
  font-size:14px;
  font-weight:500;
  cursor:pointer;
  transition:transform 0.1s ease, background 0.15s ease;
}
.ctrl-btn:active{transform:scale(0.97)}
.ctrl-btn.stop{
  background:transparent;
  border-color:var(--rec);
  color:var(--rec);
}
.ctrl-btn.stop:active{background:rgba(239,74,91,0.1)}

/* META FORM */
.meta-form{
  width:100%;
  display:flex;
  flex-direction:column;
  gap:12px;
  margin-top:20px;
}
.meta-form label{
  display:flex;
  flex-direction:column;
  gap:6px;
}
.meta-form span{
  font-size:12px;
  color:var(--text-muted);
  font-weight:500;
}
.meta-form input,.meta-form select{
  width:100%;
  padding:12px 14px;
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:10px;
  color:var(--text);
  font-family:inherit;
  font-size:14px;
  user-select:text;
  -webkit-user-select:text;
}
.meta-form input:focus,.meta-form select:focus{
  outline:none;
  border-color:var(--accent);
}

/* PROCESSING */
.processing{
  flex:1;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:20px;
  padding:40px 20px;
}
.spinner{
  width:48px;height:48px;
  border:3px solid var(--border);
  border-top-color:var(--accent);
  border-radius:50%;
  animation:spin 0.8s linear infinite;
}
@keyframes spin{to{transform:rotate(360deg)}}
.processing-text{
  font-size:16px;
  font-weight:500;
}
.processing-sub{
  font-size:13px;
  color:var(--text-muted);
}

.hide-done-toggle{
  display:flex;
  align-items:center;
  gap:6px;
  max-width:360px;
  width:100%;
  font-size:12px;
  color:var(--text-muted);
  cursor:pointer;
  user-select:none;
}
.hide-done-toggle input{
  margin:0;
  cursor:pointer;
  accent-color:var(--success);
}
.segment-list{
  list-style:none;
  width:100%;
  max-width:360px;
  display:flex;
  flex-direction:column;
  gap:6px;
  margin:4px 0;
}
.segment-list.hide-done .seg-item.done{display:none}
.seg-item{
  display:flex;
  align-items:center;
  gap:10px;
  padding:10px 12px;
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:10px;
  font-size:13px;
}
.seg-item.done{
  border-color:rgba(95,207,128,0.35);
  background:rgba(95,207,128,0.06);
}
.seg-item.failed{
  border-color:rgba(239,74,91,0.4);
  background:rgba(239,74,91,0.06);
}
.seg-label{
  font-weight:500;
  color:var(--text);
  flex-shrink:0;
}
.seg-status{
  flex:1;
  color:var(--text-muted);
  font-size:12px;
  text-align:right;
}
.seg-item.done .seg-status{color:var(--success)}
.seg-item.failed .seg-status{color:var(--rec)}
.seg-retry{
  padding:6px 12px;
  background:transparent;
  border:1px solid var(--rec);
  border-radius:8px;
  color:var(--rec);
  font-family:inherit;
  font-size:12px;
  font-weight:500;
  cursor:pointer;
}
.seg-retry:active{background:rgba(239,74,91,0.1)}
.finalize-retry{
  margin-top:16px;
  padding:12px 24px;
  background:var(--rec);
  border:none;
  border-radius:10px;
  color:#fff;
  font-family:inherit;
  font-size:14px;
  font-weight:600;
  cursor:pointer;
}
.finalize-retry:active{opacity:0.85}

/* RESULT */
.result{
  flex:1;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:16px;
  padding:40px 20px;
  text-align:center;
}
.result-icon{font-size:48px}
.result h2{
  font-size:18px;
  font-weight:700;
  color:var(--text);
}
.result-link{
  display:inline-block;
  margin-top:8px;
  padding:14px 28px;
  background:var(--accent);
  color:white;
  text-decoration:none;
  border-radius:12px;
  font-weight:600;
  font-size:14px;
  box-shadow:0 4px 16px rgba(124,106,239,0.3);
}
.result-link:active{transform:scale(0.97)}

.ghost-btn{
  padding:12px 24px;
  background:transparent;
  border:1px solid var(--border);
  color:var(--text-muted);
  border-radius:10px;
  font-family:inherit;
  font-size:13px;
  cursor:pointer;
  margin-top:12px;
}
.ghost-btn:active{background:var(--surface)}
.ghost-btn:disabled{opacity:0.5;cursor:default}

/* Storage panel (결과 화면 스토리지 요약) */
.storage-panel{
  width:100%;
  max-width:360px;
  margin:24px 0 0;
  padding:16px;
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:10px;
  font-size:13px;
}
.storage-line{
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding:4px 0;
}
.storage-line.muted{color:var(--text-muted)}
.storage-line.warn strong{color:#d97706}
.storage-panel .ghost-btn{width:100%;margin-top:12px}
.storage-msg{
  margin-top:8px;
  font-size:12px;
  color:var(--text-muted);
  min-height:16px;
}

/* ERROR */
.error{
  flex:1;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:16px;
  padding:40px 20px;
  text-align:center;
}
.error-icon{font-size:48px}
.error-text{
  font-size:14px;
  color:var(--text-muted);
  max-width:320px;
}

/* FOOTER */
.app-footer{
  padding-top:20px;
  border-top:1px solid var(--border);
  margin-top:20px;
}
.hint{
  font-size:12px;
  color:var(--text-dim);
  text-align:center;
}

.hidden{display:none !important}

/* AUTH GATE — 로컬 스토리지에 액세스 토큰 없을 때 표시 */
.auth-gate{
  flex:1;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:14px;
  padding:40px 20px;
  text-align:center;
}
.auth-icon{font-size:44px}
.auth-title{
  font-size:18px;
  font-weight:700;
  color:var(--text);
}
.auth-desc{
  font-size:13px;
  color:var(--text-muted);
  max-width:320px;
}
.auth-input{
  width:100%;
  max-width:320px;
  padding:12px 14px;
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:10px;
  color:var(--text);
  font-family:inherit;
  font-size:14px;
  user-select:text;
  -webkit-user-select:text;
}
.auth-input:focus{
  outline:none;
  border-color:var(--accent);
}
.auth-error{
  font-size:12px;
  color:var(--rec);
  margin-top:4px;
}
