:root {
  color-scheme: light;
  --ink: oklch(0.19 0.012 50);
  --muted: oklch(0.45 0.018 55);
  --quiet: oklch(0.57 0.014 58);
  --paper: oklch(0.965 0.009 76);
  --paper-deep: oklch(0.925 0.012 74);
  --field: oklch(0.99 0.006 78);
  --line: oklch(0.82 0.014 72);
  --line-strong: oklch(0.72 0.018 72);
  --backdrop: oklch(0.91 0.011 73);
  --red: oklch(0.52 0.22 28);
  --red-dark: oklch(0.39 0.18 28);
  --sage: oklch(0.47 0.055 155);
  --amber: oklch(0.55 0.095 68);
  --shadow: 0 22px 56px oklch(0.19 0.02 55 / 0.14);
  --soft-shadow: 0 10px 28px oklch(0.19 0.02 55 / 0.09);
  --page-gutter: 18px;
  --touch-size: 46px;
  --bottom-nav: 78px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  overflow-x: hidden;
  background: var(--backdrop);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  padding:
    env(safe-area-inset-top, 0px)
    env(safe-area-inset-right, 0px)
    calc(env(safe-area-inset-bottom, 0px) + var(--bottom-nav))
    env(safe-area-inset-left, 0px);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    repeating-linear-gradient(0deg, oklch(0.16 0.01 55 / 0.035) 0 1px, transparent 1px 34px),
    linear-gradient(90deg, oklch(1 0.004 80 / 0.42) 0 1px, transparent 1px 44px),
    linear-gradient(145deg, var(--backdrop), oklch(0.965 0.008 75) 48%, oklch(0.90 0.012 72));
  background-size: auto, 44px 44px, auto;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overflow-x: hidden;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation;
}

button:disabled {
  cursor: default;
  opacity: 0.58;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

.app-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  width: min(1040px, calc(100% - (var(--page-gutter) * 2)));
  margin: 0 auto;
  padding: 22px 0 16px;
}

.app-header h1 {
  margin: 0;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2.55rem;
  font-weight: 500;
  line-height: 0.9;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--red);
  font-size: 0.68rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.app-shell {
  width: min(1040px, calc(100% - (var(--page-gutter) * 2)));
  margin: 0 auto;
}

.view {
  animation: enter-view 180ms ease-out;
}

.view[hidden],
.settings-page[hidden] {
  display: none;
}

.view-heading {
  display: grid;
  gap: 7px;
  margin-bottom: 18px;
}

.view-heading h2 {
  margin: 0;
  max-width: 740px;
  font-size: 2rem;
  line-height: 1.08;
  letter-spacing: 0;
}

.view-heading p:not(.eyebrow) {
  margin: 0;
  max-width: 65ch;
  color: var(--muted);
  font-size: 0.96rem;
  line-height: 1.5;
}

.capture-surface,
.coach-card,
.carry-card,
.settings-shell {
  border: 1px solid oklch(0.18 0.01 55 / 0.11);
  border-radius: 8px;
  background:
    linear-gradient(180deg, oklch(0.99 0.005 78 / 0.96), oklch(0.95 0.011 76 / 0.96)),
    var(--paper);
  box-shadow: var(--shadow);
}

.capture-surface {
  padding: 20px;
}

.moment-form {
  display: grid;
  gap: 18px;
}

.field-group,
.field-row {
  display: grid;
  gap: 8px;
}

label,
legend,
summary {
  color: var(--ink);
  font-size: 0.91rem;
  font-weight: 780;
}

input,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--field);
  outline: none;
  box-shadow: 0 1px 0 oklch(1 0.004 80 / 0.8) inset;
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

input {
  min-height: var(--touch-size);
  padding: 10px 12px;
}

textarea {
  min-height: 112px;
  resize: vertical;
  padding: 13px;
  line-height: 1.5;
}

input:focus,
textarea:focus {
  border-color: oklch(0.54 0.18 28 / 0.55);
  background: oklch(0.995 0.005 80);
  box-shadow: 0 0 0 4px oklch(0.54 0.18 28 / 0.09), 0 1px 0 oklch(1 0.004 80 / 0.9) inset;
}

input::placeholder,
textarea::placeholder {
  color: var(--quiet);
}

.context-details {
  display: grid;
  gap: 14px;
  padding: 0;
}

.context-details summary {
  display: inline-flex;
  width: fit-content;
  min-height: 34px;
  align-items: center;
  color: var(--red-dark);
  list-style: none;
}

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

.context-grid {
  display: grid;
  gap: 14px;
  padding-top: 6px;
}

.tag-fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

.tag-fieldset legend {
  margin-bottom: 10px;
}

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

.tag-list label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 42px;
  padding: 8px 11px;
  border: 1px solid oklch(0.20 0.01 55 / 0.1);
  border-radius: 999px;
  background: oklch(0.99 0.006 76 / 0.62);
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 760;
  box-shadow: 0 1px 0 oklch(1 0.004 80 / 0.75) inset;
}

.tag-list label:has(input:checked) {
  color: var(--red-dark);
  border-color: oklch(0.54 0.18 28 / 0.42);
  background: oklch(0.94 0.035 28 / 0.72);
}

.tag-list input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--red);
}

.keep-field {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 13px 14px;
  border: 1px solid oklch(0.20 0.01 55 / 0.1);
  border-radius: 8px;
  background: oklch(0.99 0.005 76 / 0.58);
}

.keep-field input {
  width: 18px;
  min-height: 18px;
  margin-top: 2px;
  accent-color: var(--red);
}

.keep-field span {
  display: grid;
  gap: 2px;
}

.keep-field small {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.35;
}

.form-actions,
.section-actions,
.utility-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.primary-button,
.quiet-button,
.icon-button,
.tab-button,
.small-button {
  min-height: var(--touch-size);
  border: 0;
  border-radius: 8px;
  font-weight: 820;
  transition: transform 140ms ease, background 140ms ease, color 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.primary-button {
  padding: 11px 18px;
  color: oklch(0.99 0.005 78);
  background: linear-gradient(180deg, oklch(0.56 0.22 28), var(--red-dark));
  box-shadow: 0 12px 22px oklch(0.52 0.22 28 / 0.24);
}

.quiet-button,
.icon-button,
.small-button {
  padding: 9px 13px;
  color: var(--ink);
  border: 1px solid oklch(0.20 0.01 55 / 0.11);
  background: oklch(0.99 0.005 78 / 0.7);
  box-shadow: 0 1px 0 oklch(1 0.004 80 / 0.72) inset;
}

.small-button {
  min-height: 36px;
  padding: 7px 10px;
  font-size: 0.82rem;
}

.primary-button:hover,
.quiet-button:hover,
.icon-button:hover,
.small-button:hover {
  transform: translateY(-1px);
}

.primary-button:focus-visible,
.quiet-button:focus-visible,
.icon-button:focus-visible,
.small-button:focus-visible,
.tab-button:focus-visible,
summary:focus-visible {
  outline: 3px solid oklch(0.54 0.18 28 / 0.18);
  outline-offset: 2px;
}

.status-message {
  margin: 0;
  min-width: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
}

.status-message.is-error {
  color: var(--red-dark);
}

.status-message.is-success {
  color: var(--sage);
}

.status-message.is-warning {
  color: var(--amber);
}

.view-tabs {
  position: fixed;
  right: var(--page-gutter);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 10px);
  left: var(--page-gutter);
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
  width: min(560px, calc(100% - (var(--page-gutter) * 2)));
  margin: 0 auto;
  padding: 6px;
  border: 1px solid oklch(0.20 0.01 55 / 0.12);
  border-radius: 16px;
  background: oklch(0.975 0.007 76 / 0.96);
  box-shadow: 0 18px 44px oklch(0.19 0.02 55 / 0.2);
}

.tab-button {
  min-height: 48px;
  padding: 6px 4px;
  color: var(--muted);
  background: transparent;
  font-size: 0.78rem;
}

.tab-button.is-active {
  color: var(--red-dark);
  background: oklch(0.94 0.035 28 / 0.72);
  box-shadow: 0 1px 0 oklch(1 0.004 80 / 0.65) inset;
}

.coach-card,
.carry-card {
  display: grid;
  gap: 18px;
  padding: 20px;
}

.coach-card h3,
.carry-card h3,
.settings-panel h3,
.recent-section h3,
.followup-section h3 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.25;
}

.coach-headline {
  margin: 0;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.55rem;
  line-height: 1.25;
}

.coach-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.source-pill,
.count-pill,
.tag-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 6px 10px;
  border: 1px solid oklch(0.20 0.01 55 / 0.1);
  border-radius: 999px;
  color: var(--muted);
  background: oklch(0.99 0.005 78 / 0.64);
  font-size: 0.78rem;
  font-weight: 800;
}

.source-pill.is-expert {
  color: var(--sage);
  border-color: oklch(0.47 0.055 155 / 0.28);
  background: oklch(0.93 0.035 155 / 0.5);
}

.source-pill.is-local {
  color: var(--amber);
  border-color: oklch(0.55 0.095 68 / 0.28);
  background: oklch(0.94 0.045 68 / 0.44);
}

.coach-section {
  display: grid;
  gap: 7px;
  padding-top: 15px;
  border-top: 1px solid oklch(0.20 0.01 55 / 0.08);
}

.coach-section:first-child {
  padding-top: 0;
  border-top: 0;
}

.coach-section strong {
  color: var(--quiet);
  font-size: 0.76rem;
  text-transform: uppercase;
}

.coach-section p,
.carry-card p,
.empty-card p {
  margin: 0;
  color: var(--ink);
  line-height: 1.5;
}

.coach-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 18px;
  color: var(--ink);
  line-height: 1.45;
}

.section-actions {
  margin: 16px 0 24px;
}

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

.moment-list,
.followup-list,
.playbook-list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.moment-item,
.followup-item,
.playbook-item,
.pattern-item {
  display: grid;
  gap: 10px;
  padding: 15px;
  border: 1px solid oklch(0.20 0.01 55 / 0.09);
  border-radius: 8px;
  background: oklch(0.985 0.006 78 / 0.7);
  box-shadow: var(--soft-shadow);
}

.moment-topline,
.followup-topline,
.playbook-topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.moment-topline strong,
.followup-topline strong,
.playbook-topline strong {
  color: var(--ink);
  font-size: 0.95rem;
}

.moment-topline time,
.followup-topline span,
.playbook-topline span {
  flex: 0 0 auto;
  color: var(--quiet);
  font-size: 0.78rem;
  font-weight: 760;
}

.moment-item p,
.followup-item p,
.playbook-item p,
.pattern-item p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

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

.carry-move {
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.45rem;
  line-height: 1.32;
}

.pattern-grid {
  display: grid;
  gap: 12px;
}

.pattern-item strong {
  color: var(--quiet);
  font-size: 0.76rem;
  text-transform: uppercase;
}

.pattern-item span {
  color: var(--ink);
  font-size: 1.1rem;
  font-weight: 850;
}

.settings-page {
  width: min(760px, calc(100% - (var(--page-gutter) * 2)));
  margin: 0 auto;
}

.settings-shell {
  display: grid;
  gap: 20px;
  padding: 20px;
}

.settings-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.settings-heading h2 {
  margin: 0;
  font-size: 1.55rem;
  line-height: 1.16;
}

.settings-panel {
  display: grid;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid oklch(0.20 0.01 55 / 0.08);
}

.settings-panel p,
.settings-list {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.settings-list {
  display: grid;
  gap: 8px;
  padding-left: 18px;
}

.import-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

@keyframes enter-view {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (min-width: 760px) {
  :root {
    --bottom-nav: 0px;
  }

  body {
    padding-bottom: 42px;
  }

  .app-header {
    align-items: center;
    padding-top: 32px;
    padding-bottom: 24px;
  }

  .app-header h1 {
    font-size: 5.4rem;
  }

  .app-shell {
    display: grid;
    grid-template-columns: 164px minmax(0, 1fr);
    gap: 26px;
    align-items: start;
  }

  .view-tabs {
    position: sticky;
    top: 22px;
    right: auto;
    bottom: auto;
    left: auto;
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
    margin: 0;
    border-radius: 8px;
    box-shadow: var(--soft-shadow);
  }

  .tab-button {
    justify-content: flex-start;
    padding: 10px 12px;
    text-align: left;
  }

  .capture-surface,
  .coach-card,
  .carry-card,
  .settings-shell {
    padding: 28px;
  }

  .view-heading h2 {
    font-size: 2.35rem;
  }

  .field-row {
    grid-template-columns: 160px minmax(0, 1fr);
    align-items: center;
  }

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

  .context-grid .field-group:last-child {
    grid-column: 1 / -1;
  }

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

@media (max-width: 420px) {
  :root {
    --page-gutter: 12px;
  }

  .app-header h1 {
    font-size: 2.1rem;
  }

  .icon-button {
    min-height: 40px;
    padding: 8px 10px;
    font-size: 0.82rem;
  }

  .view-heading h2 {
    font-size: 1.55rem;
  }

  .capture-surface,
  .coach-card,
  .carry-card,
  .settings-shell {
    padding: 16px;
  }

  .tag-list label {
    flex: 1 1 calc(50% - 9px);
  }

  .tab-button {
    font-size: 0.72rem;
  }
}
