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

:root {
  --bg:       #0d0d1a;
  --surface:  #161628;
  --surface2: #1f1f38;
  --accent:   #6c63ff;
  --accent2:  #4e46cc;
  --danger:   #e74c3c;
  --success:  #27ae60;
  --warn:     #e67e22;
  --text:     #e8e8f4;
  --muted:    #888899;
  --border:   #2a2a45;
  --radius:   14px;
}

html { font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

/* ── Header ─────────────────────────────────────────────── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-header h1 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.header-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(108,99,255,0.12);
  transition: background 0.2s;
}
.header-link:active { background: rgba(108,99,255,0.25); }

/* ── Recording screen ────────────────────────────────────── */
.record-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100dvh - 56px);
  padding: 24px 20px;
  gap: 28px;
}

.status-text {
  font-size: 17px;
  color: var(--muted);
  text-align: center;
  min-height: 26px;
  transition: color 0.25s;
  line-height: 1.4;
}
.status-text a { color: var(--accent); }
.status-recording { color: var(--danger) !important; }
.status-sending   { color: var(--warn)    !important; }
.status-done      { color: var(--success) !important; }
.status-error     { color: var(--danger)  !important; }

.record-btn {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  border: none;
  background: var(--surface2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 52px;
  box-shadow: 0 6px 30px rgba(0,0,0,0.4);
  transition: transform 0.15s, background 0.25s;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
.record-btn:active  { transform: scale(0.94); }
.record-btn.is-recording {
  background: var(--danger);
  animation: pulse-ring 1.5s ease-in-out infinite;
}

@keyframes pulse-ring {
  0%, 100% { box-shadow: 0 0 0 0   rgba(231,76,60,.45); }
  50%       { box-shadow: 0 0 0 22px rgba(231,76,60,.0); }
}

.record-timer {
  font-size: 36px;
  font-weight: 300;
  font-variant-numeric: tabular-nums;
  letter-spacing: 2px;
  color: var(--text);
}

.record-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 320px;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: block;
  width: 100%;
  padding: 15px;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  text-align: center;
  font-family: inherit;
}
.btn:active { transform: scale(0.97); opacity: 0.85; }

.btn-primary   { background: var(--accent);  color: #fff; }
.btn-secondary { background: var(--surface2); color: var(--muted); }
.btn-danger    {
  background: rgba(231,76,60,.12);
  color: var(--danger);
  border: 1px solid rgba(231,76,60,.25);
}
.btn-sm {
  padding: 8px 14px;
  font-size: 14px;
  border-radius: 8px;
  width: auto;
  display: inline-block;
}

/* ── Error banner ────────────────────────────────────────── */
.error-banner {
  background: rgba(231,76,60,.12);
  border: 1px solid rgba(231,76,60,.3);
  border-radius: 10px;
  color: var(--danger);
  font-size: 14px;
  padding: 10px 14px;
  text-align: center;
  max-width: 320px;
  line-height: 1.4;
}

/* ── Login ───────────────────────────────────────────────── */
.login-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 24px;
  gap: 24px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.login-card h2 {
  font-size: 22px;
  text-align: center;
}

/* ── Form controls ───────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}
.form-control {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  width: 100%;
  transition: border-color 0.2s;
}
.form-control:focus {
  outline: none;
  border-color: var(--accent);
}
textarea.form-control {
  min-height: 90px;
  resize: vertical;
  line-height: 1.5;
}
select.form-control {
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23888899' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

/* ── Tasks list ──────────────────────────────────────────── */
.page-body {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.task-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.task-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.2s;
}
.task-card:active { border-color: var(--accent); }

.task-card-title {
  flex: 1;
  font-size: 15px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.4;
}

.task-card-meta {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

/* ── Status badges ───────────────────────────────────────── */
.badge {
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}
.badge-inbox       { background: rgba(108,99,255,.18); color: var(--accent); }
.badge-in_progress { background: rgba(230,126,34,.18); color: var(--warn);   }
.badge-done        { background: rgba(39,174,96,.18);  color: var(--success);}

/* ── Task detail ─────────────────────────────────────────── */
.task-detail {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding-bottom: 100px; /* leave room for sticky save bar */
}

.audio-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
}
.audio-block audio {
  width: 100%;
  accent-color: var(--accent);
}
.audio-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sticky-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 12px 16px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
}

.transcription-box {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
}

/* ── Empty state ─────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
}

/* ── Utilities ───────────────────────────────────────────── */
.hidden          { display: none !important; }
.back-link       { color: var(--muted); text-decoration: none; font-size: 14px; }
.back-link::before { content: "← "; }
.spinner         { color: var(--muted); text-align: center; padding: 30px; }
