:root {
  --bg: oklch(1 0 0);
  --surface: oklch(0.955 0.006 205);
  --ink: oklch(0.27 0.02 215);
  --muted: oklch(0.4 0.02 215);
  --line: oklch(0.86 0.012 205);
  --primary: oklch(0.46 0.13 198);
  --primary-deep: oklch(0.39 0.12 198);
  --sans: "Segoe UI", "Helvetica Neue", sans-serif;
  --serif: Georgia, "Iowan Old Style", "Palatino Linotype", Palatino, serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  color-scheme: light;
}

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

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
}

button,
textarea {
  font: inherit;
  color: inherit;
}

h1,
h2 {
  text-wrap: balance;
}

h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

h2 {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

p {
  text-wrap: pretty;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 2;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--ink);
}

.skip:focus {
  top: 12px;
}

.page {
  max-width: 72ch;
  margin: 0 auto;
  padding: 28px 28px 64px;
}

.lede {
  margin: 10px 0 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted);
}

.title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.rec {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 11.5rem;
  margin: 0 8px 0 0;
  font-size: 14px;
}

.lamp {
  width: 9px;
  height: 9px;
  border: 1.5px solid var(--muted);
  border-radius: 50%;
  background: transparent;
  flex: none;
}

.is-recording .lamp {
  border-color: var(--primary);
  background: var(--primary);
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.clock {
  display: inline-block;
  min-width: 7.2ch;
  font-variant-numeric: tabular-nums;
}

.btn {
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--ink);
  border-radius: 4px;
  background: var(--bg);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

.btn:hover {
  background: var(--surface);
}

.btn:active {
  transform: translateY(1px);
}

.btn:focus-visible,
textarea:focus-visible,
.skip:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.btn-primary:hover,
.btn-primary:active {
  background: var(--primary-deep);
  border-color: var(--primary-deep);
  color: white;
}

.alert {
  margin: 16px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--ink);
  font-size: 14px;
}

#writing {
  margin-top: 24px;
}

.draft {
  display: block;
  width: 100%;
  height: 70vh;
  min-height: 420px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--bg);
  font-family: var(--serif);
  font-size: 20px;
  line-height: 1.55;
  resize: vertical;
}

.draft::placeholder {
  color: var(--muted);
  opacity: 1;
}

.status-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.status-line span {
  margin: 0;
}

code {
  font-family: var(--mono);
  font-size: 0.92em;
}

.settings-host {
  position: fixed;
  z-index: 20;
  top: 16px;
  right: 16px;
  width: 300px;
  color-scheme: dark;
}

.atype-panel {
  box-sizing: border-box;
  width: 300px;
  max-height: calc(100vh - 32px);
  overflow: auto;
  background: #1a1814;
  color: #ece7dc;
  border: 1px solid #3c3428;
  font: 12px/1.35 "Segoe UI", system-ui, sans-serif;
}

.atype-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  background: #241f19;
  user-select: none;
}

.atype-bar b {
  font-weight: 600;
  letter-spacing: 0.02em;
}

.atype-x,
.atype-btn,
.atype-primary {
  font: inherit;
  color: #ece7dc;
  background: transparent;
  border: 1px solid #3c3428;
  padding: 4px 8px;
  cursor: pointer;
}

.atype-x {
  border: 0;
  padding: 2px 4px;
}

.atype-primary {
  background: #e6a317;
  color: #1a1814;
  border-color: #e6a317;
}

.atype-x:hover,
.atype-btn:hover {
  background: #2a241c;
}

.atype-primary:hover {
  background: #f0b429;
}

.atype-x:focus-visible,
.atype-btn:focus-visible,
.atype-primary:focus-visible,
.atype-field input:focus-visible,
.atype-select:focus-visible,
.atype-details summary:focus-visible {
  outline: 1px solid #e6a317;
  outline-offset: 1px;
}

.atype-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
}

.atype-note,
.atype-status {
  margin: 0;
  color: #a39b8c;
  font-size: 11px;
  line-height: 1.4;
}

.atype-cat {
  color: #ece7dc;
  font-size: 11px;
}

.atype-skill {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.atype-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 8px;
}

.atype-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: #a39b8c;
  font-size: 11px;
}

.atype-field input,
.atype-select {
  box-sizing: border-box;
  width: 100%;
  background: #100e0c;
  color: #ece7dc;
  border: 1px solid #3c3428;
  padding: 4px 6px;
  font: 12px/1.3 "Segoe UI", system-ui, sans-serif;
}

.atype-check {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  color: #a39b8c;
  font-size: 11px;
}

.atype-details {
  border-top: 1px solid #3c3428;
  padding-top: 6px;
}

.atype-details summary {
  cursor: pointer;
  color: #ece7dc;
}

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

@media (max-width: 720px) {
  .settings-host {
    left: 12px;
    right: 12px;
    width: auto;
  }

  .atype-panel {
    width: 100%;
  }
}

dialog {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  max-width: min(28rem, calc(100vw - 32px));
  background: var(--bg);
  color: var(--ink);
}

dialog::backdrop {
  background: oklch(0.27 0.02 215 / 0.35);
}

dialog p {
  margin: 0 0 16px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

::selection {
  background: color-mix(in oklch, var(--primary) 24%, white);
  color: var(--ink);
}

@media (max-width: 860px) {
  .page {
    padding: 16px 16px 40px;
  }

  .draft {
    height: 60vh;
    min-height: 320px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .is-recording .lamp,
  .btn {
    animation: none;
    transition: none;
  }

  .btn:active {
    transform: none;
  }
}
