:root {
  color-scheme: light;
  --bg: #f4f7f8;
  --panel: #ffffff;
  --panel-strong: #ecf3f1;
  --text: #172026;
  --muted: #5d6b73;
  --line: #d9e2e4;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --danger: #b42318;
  --warning: #a15c07;
  --shadow: 0 18px 42px rgba(17, 32, 38, 0.1);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

body.locked .app-shell {
  display: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 0 14px;
  font-weight: 700;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.app-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 14px 28px;
}

.lock-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 18px;
}

body:not(.locked) .lock-screen {
  display: none;
}

.lock-box {
  display: grid;
  gap: 14px;
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 22px;
}

.lock-error {
  color: var(--danger);
  font-size: 13px;
  font-weight: 700;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 2px 18px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.1;
}

h2 {
  font-size: 20px;
}

h3 {
  font-size: 15px;
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.95fr) minmax(320px, 1.25fr);
  gap: 14px;
}

.recorder-panel,
.library-panel,
.detail-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 16px;
}

.detail-panel {
  grid-column: 1 / -1;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.state-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  background: var(--panel-strong);
  color: var(--accent-strong);
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
}

.field {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
}

.field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  padding: 12px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.timer-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfb;
  margin: 12px 0;
  padding: 13px;
}

.timer-row strong {
  font-variant-numeric: tabular-nums;
  font-size: 28px;
  line-height: 1;
}

.timer-row span,
.status-box {
  color: var(--muted);
  font-size: 13px;
}

.controls,
.action-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.action-grid {
  grid-template-columns: repeat(4, 1fr);
  margin: 12px 0;
}

.primary-action {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.danger {
  border-color: rgba(180, 35, 24, 0.25);
  color: var(--danger);
}

.status-box {
  min-height: 44px;
  border-left: 3px solid var(--accent);
  background: #eff7f5;
  border-radius: 8px;
  margin-top: 12px;
  padding: 10px 12px;
}

.small-button,
.icon-button {
  min-height: 38px;
  padding: 0 12px;
}

.icon-button {
  width: 42px;
  padding: 0;
  font-size: 22px;
}

.recording-list {
  display: grid;
  gap: 9px;
  max-height: 480px;
  overflow: auto;
  padding-right: 2px;
}

.date-heading {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(244, 247, 248, 0.96);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  padding: 8px 10px;
  text-transform: capitalize;
}

.recording-card {
  display: grid;
  gap: 7px;
  width: 100%;
  min-height: 78px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  text-align: left;
}

.recording-card strong {
  overflow-wrap: anywhere;
}

.recording-card span {
  color: var(--muted);
  font-size: 12px;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  border-radius: 999px;
  background: #eef2f2;
  color: #405057;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 700;
}

audio {
  width: 100%;
}

.content-block {
  border-top: 1px solid var(--line);
  margin-top: 14px;
  padding-top: 14px;
}

.ai-block {
  border: 1px solid #c9dddd;
  border-radius: 8px;
  background: #fbfdfc;
  margin-top: 16px;
  padding: 14px;
}

.content-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

pre {
  max-height: 460px;
  overflow: auto;
  margin: 10px 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: #24333a;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
}

.markdown-output {
  display: grid;
  gap: 10px;
  max-height: 560px;
  overflow: auto;
  color: #24333a;
  font-size: 15px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.markdown-output h1,
.markdown-output h2,
.markdown-output h3 {
  margin: 8px 0 0;
  color: #111827;
  line-height: 1.2;
}

.markdown-output h1 {
  font-size: 22px;
}

.markdown-output h2 {
  font-size: 18px;
}

.markdown-output h3 {
  font-size: 16px;
}

.markdown-output p {
  margin: 0;
}

.markdown-output ul,
.markdown-output ol {
  margin: 0;
  padding-left: 24px;
}

.markdown-output li {
  margin: 4px 0;
}

.markdown-output code {
  border: 1px solid #d7e3e2;
  border-radius: 6px;
  background: #eef6f4;
  padding: 1px 5px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
}

.markdown-output pre {
  max-height: none;
  border: 1px solid #d7e3e2;
  border-radius: 8px;
  background: #0f172a;
  color: #e5eef0;
  margin: 0;
  padding: 12px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
}

.markdown-output blockquote {
  border-left: 3px solid var(--accent);
  color: var(--muted);
  margin: 0;
  padding: 4px 0 4px 12px;
}

.markdown-output a {
  color: var(--accent-strong);
  font-weight: 700;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 14px;
}

.hidden {
  display: none !important;
}

@media (max-width: 760px) {
  .app-shell {
    padding-inline: 10px;
  }

  .main-grid,
  .controls,
  .action-grid {
    grid-template-columns: 1fr;
  }

  .recorder-panel,
  .library-panel,
  .detail-panel {
    padding: 14px;
  }

  .timer-row {
    align-items: flex-start;
    flex-direction: column;
  }
}
