:root {
  color-scheme: light;
  --bg: #f5f2ee;
  --surface: #ffffffd6;
  --surface-soft: #fffaf5;
  --text: #1e1a17;
  --muted: #6f655b;
  --line: #eadfd2;
  --line-strong: #e5c9af;
  --primary: #e45f2b;
  --primary-dark: #c94f20;
  --danger: #a02240;
  --radius: 20px;
  --radius-sm: 14px;
  --shadow: 0 24px 60px rgba(36, 22, 9, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 6%, #ffeedc 0%, transparent 34%),
    radial-gradient(circle at 86% 2%, #ffead8 0%, transparent 28%),
    radial-gradient(circle at 40% 118%, #f3e9de 0%, #f0e7dc 56%, #ebe1d6 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(rgba(31, 25, 20, 0.06) 1px, transparent 1px);
  background-size: 22px 22px;
  opacity: 0.56;
}

body::after {
  content: "";
  position: fixed;
  width: min(420px, 64vw);
  aspect-ratio: 1;
  top: -160px;
  right: -120px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(236, 174, 130, 0.22), transparent 65%);
  filter: blur(10px);
  pointer-events: none;
}

a {
  color: #9d431f;
}

.shell {
  position: relative;
  z-index: 1;
  width: min(1140px, calc(100% - 24px));
  margin: 18px auto 40px;
  display: grid;
  gap: 16px;
}

.topbar {
  position: relative;
  overflow: hidden;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 24px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: linear-gradient(145deg, #ffffff, #fff6ee 48%, #fff8f4 100%);
  box-shadow: var(--shadow);
}

.topbar::after {
  content: "";
  position: absolute;
  width: 210px;
  height: 210px;
  border-radius: 50%;
  top: -124px;
  right: -88px;
  background: radial-gradient(circle, rgba(228, 95, 43, 0.22), transparent 62%);
}

.topbar > div {
  position: relative;
  max-width: 76ch;
}

.hero-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--primary);
  font-weight: 700;
}

.language-switch {
  display: grid;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
}

.language-switch select {
  min-width: 124px;
  padding: 6px 8px;
  border-radius: 10px;
}

h1,
h2 {
  margin: 0;
  font-family: "Spectral", serif;
}

h1 {
  font-size: clamp(1.95rem, 2.8vw, 2.75rem);
  line-height: 1.1;
}

h2 {
  font-size: clamp(1.22rem, 1.8vw, 1.62rem);
  margin-bottom: 12px;
}

.subtitle {
  margin: 10px 0 0;
  color: var(--muted);
  max-width: 72ch;
  line-height: 1.5;
}

.status {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  background: #fff9f4;
  color: #715840;
  box-shadow: 0 10px 24px rgba(71, 37, 17, 0.04);
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.auth-panel {
  max-width: 460px;
  margin: 0 auto;
}

.auth-form .actions {
  justify-content: flex-start;
}

.auth-form .btn {
  min-width: 180px;
}

.auth-divider {
  margin: 8px 0;
  color: var(--muted);
  font-size: 0.92rem;
  text-transform: lowercase;
}

#appPanel {
  display: grid;
  gap: 16px;
}

.quick-panel {
  background: linear-gradient(145deg, #fff, #fff7ef 58%, #fff4eb 100%);
}

.quick-grid {
  margin-top: 12px;
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.quick-step {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: #fffdfb;
  display: grid;
  gap: 8px;
  transition: transform 180ms ease, border-color 180ms ease;
}

.quick-step:hover {
  transform: translateY(-2px);
  border-color: #e3b996;
}

.quick-step span {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #ffe3cf;
  color: var(--primary-dark);
  font-weight: 700;
}

.quick-step p {
  margin: 0;
  font-size: 14px;
}

.grid {
  display: grid;
  gap: 11px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stack {
  display: grid;
  gap: 11px;
}

label {
  display: grid;
  gap: 6px;
  font-weight: 600;
  color: var(--text);
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 11px;
  background: #fffefc;
  color: var(--text);
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input::placeholder,
textarea::placeholder {
  color: #8c7d6e;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 0;
  border-color: #e2ac84;
  box-shadow: 0 0 0 3px rgba(228, 95, 43, 0.16);
}

textarea {
  resize: vertical;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.quick-reminders {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 0 0 12px;
}

.flow-builder {
  display: grid;
  gap: 8px;
  margin: 0 0 12px;
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  padding: 12px;
  background: #fff9f2;
}

.flow-preview {
  margin-top: 4px;
}

.flow-steps-list {
  margin: 10px 0 0;
  padding-left: 18px;
  display: grid;
  gap: 8px;
}

.flow-step-item {
  color: #5f5348;
  line-height: 1.4;
}

.flow-step-title {
  font-weight: 700;
  color: #513724;
}

.quick-reminder-btn {
  min-height: 34px;
  padding: 6px 12px;
  font-size: 0.92rem;
}

.simple-details {
  border: 1px dashed var(--line-strong);
  border-radius: 14px;
  background: #fffaf6;
  padding: 9px 11px;
}

.simple-details > summary {
  position: relative;
  list-style: none;
  cursor: pointer;
  font-weight: 600;
  color: var(--muted);
  padding-right: 20px;
}

.simple-details > summary::-webkit-details-marker {
  display: none;
}

.simple-details > summary::after {
  content: "";
  position: absolute;
  right: 4px;
  top: 42%;
  width: 8px;
  height: 8px;
  border-right: 2px solid #947b67;
  border-bottom: 2px solid #947b67;
  transform: rotate(45deg) translateY(-50%);
  transition: transform 180ms ease;
}

.simple-details[open] > summary::after {
  transform: rotate(225deg) translateY(-50%);
  top: 56%;
}

.details-body {
  margin-top: 10px;
}

.btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  min-height: 40px;
  padding: 8px 14px;
  cursor: pointer;
  color: #5c311a;
  text-decoration: none;
  font-weight: 700;
  transition:
    transform 150ms ease,
    box-shadow 180ms ease,
    border-color 180ms ease,
    background 180ms ease;
}

.btn:hover:not([disabled]) {
  transform: translateY(-1px);
  border-color: #e0b998;
  box-shadow: 0 10px 20px rgba(105, 51, 22, 0.08);
}

.btn.primary {
  border-color: transparent;
  background: linear-gradient(180deg, var(--primary), var(--primary-dark));
  color: #fff;
}

.btn.ghost {
  background: #fffaf4;
}

.btn.danger {
  border-color: #f1c1cb;
  color: var(--danger);
  background: #fff8f9;
}

.btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.capture-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: linear-gradient(130deg, #fffefc, #fff9f2);
}

.selected-patient-line {
  margin: 2px 0 12px;
  color: var(--muted);
}

.selected-patient-line strong {
  color: #8b401f;
}

#iphoneCaptureHint {
  margin-top: 8px;
}

.muted {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.list-wrap {
  overflow-x: auto;
  border: 1px solid #efe2d6;
  border-radius: 14px;
  background: #fff;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th,
.table td {
  border-bottom: 1px solid #f2e8de;
  text-align: left;
  padding: 10px 8px;
  vertical-align: top;
}

.table th {
  position: sticky;
  top: 0;
  background: #fffaf5;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.table tbody tr:nth-child(2n) {
  background: #fffdfa;
}

.table tbody tr:hover {
  background: #fff4ea;
}

.table td pre {
  margin: 0;
  white-space: pre-wrap;
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.table-actions .btn {
  min-height: 32px;
  padding: 5px 10px;
  font-size: 12px;
}

audio {
  margin-top: 8px;
  width: 100%;
}

.legal-footer {
  margin-top: 12px;
}

.legal-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border: 1px solid #e3d4c6;
  border-radius: 999px;
  background: rgba(255, 248, 240, 0.9);
  color: #6f655b;
  font-size: 0.84rem;
  text-decoration: none;
}

.legal-link::before {
  content: "🛡";
  font-size: 0.75rem;
  line-height: 1;
}

.legal-link:visited,
.legal-link:hover,
.legal-link:active {
  color: #6f655b;
  text-decoration: none;
}

.legal-link:hover {
  border-color: #d8c5b4;
  background: #fff4e9;
}

@media (max-width: 980px) {
  .shell {
    width: min(100%, calc(100% - 14px));
    margin: 10px auto 26px;
    gap: 10px;
  }

  .topbar,
  .panel {
    padding: 14px;
  }

  input,
  select,
  textarea,
  button {
    font-size: 16px;
  }

  .grid.two,
  .grid.three,
  .quick-grid {
    grid-template-columns: 1fr;
  }

  .topbar,
  .capture-box {
    flex-direction: column;
    align-items: flex-start;
  }

  .actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .actions .btn {
    width: 100%;
    min-height: 44px;
  }
}
