:root {
  color-scheme: light;
  --navy: #0b3147;
  --navy-2: #164a65;
  --blue: #0b789e;
  --blue-soft: #e9f4f8;
  --amber: #f3b51b;
  --red: #b42318;
  --red-soft: #fff0ee;
  --ink: #17252d;
  --muted: #61727c;
  --line: #d9e2e7;
  --surface: #ffffff;
  --canvas: #f3f6f8;
  --shadow: 0 10px 28px rgba(18, 47, 62, .08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--canvas);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.45;
}

button, input, select, textarea { font: inherit; }
button { touch-action: manipulation; }

.app-header {
  min-height: 86px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px clamp(18px, 3vw, 42px);
  color: white;
  background: linear-gradient(115deg, var(--navy), var(--navy-2));
  border-bottom: 4px solid var(--amber);
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.35rem, 2.4vw, 2rem); letter-spacing: -.025em; }
h2 { margin-bottom: 0; font-size: clamp(1.25rem, 2vw, 1.55rem); letter-spacing: -.018em; }
.eyebrow { margin-bottom: 3px; font-size: .75rem; font-weight: 800; letter-spacing: .13em; color: #9bd7eb; }

.privacy-note { display: flex; align-items: center; gap: 9px; font-size: .9rem; white-space: nowrap; }
.privacy-dot { width: 10px; height: 10px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 0 4px rgba(74,222,128,.16); }

.steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  padding: 0 clamp(18px, 3vw, 42px);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.step {
  min-height: 58px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}
.step span { display: inline-grid; place-items: center; width: 26px; height: 26px; margin-right: 8px; border: 1px solid var(--line); border-radius: 50%; }
.step.is-active { color: var(--navy); border-bottom-color: var(--blue); }
.step.is-active span { color: white; background: var(--blue); border-color: var(--blue); }

main { max-width: 1500px; margin: 0 auto; padding: clamp(18px, 3vw, 36px); }

.session-bar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.session-fields { display: flex; align-items: end; gap: 28px; }
label, .state-label { display: block; margin-bottom: 6px; color: var(--muted); font-size: .86rem; font-weight: 750; }
select, input[type="search"] { min-height: 48px; border: 1px solid #b9c7cf; border-radius: 10px; background: white; color: var(--ink); }
select { min-width: 190px; padding: 0 38px 0 13px; font-weight: 750; }
.session-state { min-width: 140px; padding-bottom: 4px; }
.session-state strong { display: block; color: var(--navy); }

.primary-button, .secondary-button {
  min-height: 50px;
  padding: 0 20px;
  border-radius: 10px;
  font-weight: 800;
  cursor: pointer;
}
.primary-button { border: 1px solid var(--blue); background: var(--blue); color: white; }
.primary-button:active { transform: translateY(1px); }
.secondary-button { width: 100%; border: 1px solid var(--navy); background: white; color: var(--navy); }
.secondary-button:disabled { cursor: not-allowed; opacity: .45; }

.workspace-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(310px, .8fr); gap: 22px; align-items: start; }
.quick-panel, .observations-panel { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.quick-panel { padding: 22px; }
.observations-panel { position: sticky; top: 18px; padding: 22px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.section-heading .eyebrow { color: var(--blue); }
.section-heading.compact { align-items: center; }
.search-field { margin: 0; }
.search-field input { width: min(310px, 34vw); padding: 0 14px; }

.quick-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.shortcut-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: -6px 0 14px; }
.shortcut-heading p { margin: 0; color: var(--muted); font-size: .9rem; }
.shortcut-back { min-height: 42px; padding: 0 13px; border: 1px solid var(--navy); border-radius: 9px; background: white; color: var(--navy); font-weight: 800; cursor: pointer; }
.shortcut-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 11px; }
.shortcut-tile {
  min-height: 86px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px;
  border: 1px solid #bed0d9;
  border-radius: 12px;
  background: #fbfdfe;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.shortcut-tile:hover, .shortcut-tile:focus-visible { border-color: var(--blue); background: var(--blue-soft); outline: 3px solid rgba(11,120,158,.16); }
.shortcut-symbol { flex: 0 0 auto; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; background: var(--navy); color: white; font-size: .74rem; font-weight: 900; letter-spacing: .02em; }
.shortcut-tile strong, .shortcut-tile small { display: block; }
.shortcut-tile strong { font-size: .9rem; line-height: 1.25; }
.shortcut-tile small { margin-top: 3px; color: var(--muted); font-size: .72rem; font-weight: 650; }
.shortcut-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; padding: 2px 0 4px; }
.shortcut-action {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 15px;
  border: 1px solid #aac5d1;
  border-left: 5px solid var(--blue);
  border-radius: 11px;
  background: white;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.shortcut-action strong, .shortcut-action small { display: block; }
.shortcut-action strong { font-size: .95rem; line-height: 1.3; }
.shortcut-action small { margin-top: 3px; color: var(--muted); font-size: .74rem; }
.shortcut-action::after { content: '+'; flex: 0 0 auto; display: grid; place-items: center; width: 31px; height: 31px; border-radius: 8px; background: var(--blue-soft); color: var(--blue); font-size: 1.25rem; font-weight: 850; }
.shortcut-action:not(:disabled):hover, .shortcut-action:not(:disabled):focus-visible { border-color: var(--blue); background: var(--blue-soft); outline: 3px solid rgba(11,120,158,.16); }
.shortcut-action:disabled { cursor: not-allowed; opacity: .48; }
.all-errors-panel { margin-top: 18px; border: 1px solid var(--line); border-radius: 11px; background: #f8fafb; overflow: hidden; }
.all-errors-panel summary { min-height: 49px; display: flex; align-items: center; padding: 0 15px; color: var(--navy); font-size: .9rem; font-weight: 800; cursor: pointer; }
.all-errors-panel summary::marker { color: var(--blue); }
.all-errors-body { padding: 0 14px 14px; border-top: 1px solid var(--line); }
.full-search { display: block; padding-top: 14px; }
.full-search input { width: 100%; }
.quick-footer-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.quick-footer-actions .add-custom-button { margin-top: 0; }
.quick-critical-button { min-height: 52px; border: 1px solid #d92d20; border-radius: 11px; background: var(--red-soft); color: #8f2017; font-weight: 820; cursor: pointer; }
.quick-critical-button:disabled { cursor: not-allowed; opacity: .5; }
.quick-action {
  min-height: 88px;
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 14px;
  border: 1px solid #bed0d9;
  border-radius: 12px;
  background: #fbfdfe;
  color: var(--ink);
  text-align: left;
  font-weight: 760;
  cursor: pointer;
}
.quick-action:not(:disabled):hover, .quick-action:not(:disabled):focus-visible { border-color: var(--blue); background: var(--blue-soft); outline: 3px solid rgba(11,120,158,.16); }
.quick-action:disabled { cursor: not-allowed; opacity: .48; }
.quick-action.is-critical { border-color: #efb4ae; background: var(--red-soft); color: #781b13; }
.action-icon { flex: 0 0 auto; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; color: white; background: var(--navy-2); font-size: .9rem; font-weight: 900; }
.is-critical .action-icon { background: var(--red); }

.count-badge { display: inline-grid; place-items: center; min-width: 30px; height: 30px; padding: 0 8px; margin-left: 5px; border-radius: 99px; background: var(--blue-soft); color: var(--blue); font-size: .92rem; }
.empty-state { min-height: 220px; display: grid; place-content: center; justify-items: center; padding: 22px; border: 1px dashed #b9c7cf; border-radius: 12px; color: var(--muted); text-align: center; }
.empty-state p { max-width: 32ch; margin-bottom: 0; }
.empty-mark { display: grid; place-items: center; width: 52px; height: 52px; margin-bottom: 12px; border-radius: 50%; background: var(--blue-soft); color: var(--blue); font-size: 2rem; }
.observation-list { display: grid; gap: 10px; margin: 0 0 16px; padding: 0; list-style: none; }
.observation-item { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
.observation-item strong { font-size: .94rem; }
.item-count { display: grid; place-items: center; min-width: 34px; height: 34px; border-radius: 8px; background: var(--navy); color: white; font-weight: 800; }
.remove-item { min-width: 38px; min-height: 38px; border: 0; border-radius: 8px; background: #f1f4f6; color: var(--muted); font-size: 1.25rem; cursor: pointer; }

.toast { position: fixed; left: 50%; bottom: 28px; z-index: 20; transform: translate(-50%, 24px); padding: 11px 16px; border-radius: 999px; background: var(--navy); color: white; font-weight: 700; opacity: 0; pointer-events: none; transition: .18s ease; box-shadow: var(--shadow); }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.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; }

@media (max-width: 980px) {
  .workspace-grid { grid-template-columns: 1fr; }
  .observations-panel { position: static; }
  .quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .shortcut-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  .app-header, .session-bar, .section-heading { align-items: stretch; flex-direction: column; }
  .privacy-note { white-space: normal; }
  .steps { overflow-x: auto; grid-template-columns: repeat(4, minmax(145px, 1fr)); }
  .session-fields { align-items: stretch; flex-direction: column; gap: 14px; }
  select { width: 100%; }
  .search-field input { width: 100%; }
  .quick-grid { grid-template-columns: 1fr; }
  .shortcut-grid, .shortcut-actions, .quick-footer-actions { grid-template-columns: 1fr; }
  .shortcut-heading { align-items: stretch; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}

[hidden] { display: none !important; }

.header-meta { display: flex; align-items: center; gap: 18px; }
.header-session { padding: 7px 11px; border: 1px solid rgba(255,255,255,.32); border-radius: 8px; background: rgba(255,255,255,.08); font-size: .86rem; font-weight: 750; }

.app-view { display: none; }
.app-view.is-active { display: block; }

.filter-strip { display: flex; gap: 8px; margin: 0 0 18px; padding: 2px 2px 8px; overflow-x: auto; scrollbar-width: thin; }
.filter-button { flex: 0 0 auto; min-height: 42px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px; background: white; color: var(--muted); font-size: .9rem; font-weight: 760; cursor: pointer; }
.filter-button.is-active { border-color: var(--navy); background: var(--navy); color: white; }
.filter-button:focus-visible { outline: 3px solid rgba(11,120,158,.2); outline-offset: 2px; }

.quick-action .action-copy { display: grid; gap: 3px; }
.quick-action small { color: var(--muted); font-size: .76rem; font-weight: 650; }
.quick-action.is-critical small { color: #8d352d; }
.add-custom-button { width: 100%; min-height: 52px; margin-top: 14px; border: 1px dashed var(--blue); border-radius: 11px; background: var(--blue-soft); color: var(--navy); font-weight: 800; cursor: pointer; }
.add-custom-button:disabled { cursor: not-allowed; opacity: .5; }

.observation-copy { min-width: 0; }
.observation-copy strong, .observation-copy small { display: block; }
.observation-copy small { margin-top: 2px; color: var(--muted); font-size: .76rem; }
.observation-tools { display: flex; gap: 5px; }
.mini-button { min-width: 38px; min-height: 38px; border: 0; border-radius: 8px; background: #eef3f5; color: var(--navy); font-size: 1.1rem; font-weight: 800; cursor: pointer; }

.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 20px; padding: 20px 22px; border: 1px solid var(--line); border-left: 5px solid var(--blue); border-radius: 14px; background: white; box-shadow: var(--shadow); }
.page-heading p:last-child { max-width: 72ch; margin: 6px 0 0; color: var(--muted); }
.fit-button { width: auto; flex: 0 0 auto; }
.danger-button { min-height: 48px; padding: 0 16px; border: 1px solid #d92d20; border-radius: 10px; background: white; color: #b42318; font-weight: 800; cursor: pointer; }

.empty-page { padding: 48px 24px; border: 1px dashed #b9c7cf; border-radius: 14px; background: rgba(255,255,255,.7); color: var(--muted); text-align: center; }
.empty-page strong { display: block; margin-bottom: 5px; color: var(--ink); font-size: 1.08rem; }

.review-list, .comments-list, .history-list { display: grid; gap: 16px; }
.review-card, .comment-card, .history-card { border: 1px solid var(--line); border-radius: 15px; background: white; box-shadow: var(--shadow); overflow: hidden; }
.review-card summary { list-style: none; cursor: pointer; }
.review-card summary::-webkit-details-marker { display: none; }
.review-summary { display: grid; grid-template-columns: auto minmax(0,1fr) auto auto; align-items: center; gap: 14px; min-height: 76px; padding: 14px 18px; }
.review-index { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--navy); color: white; font-weight: 850; }
.review-summary-copy { min-width: 0; }
.review-summary-copy strong, .review-summary-copy small { display: block; }
.review-summary-copy small { margin-top: 3px; color: var(--muted); }
.competency-pill { max-width: 270px; padding: 6px 10px; border-radius: 999px; background: var(--blue-soft); color: var(--navy); font-size: .78rem; font-weight: 760; text-align: center; }
.chevron { color: var(--blue); font-size: 1.25rem; transition: transform .16s ease; }
.review-card[open] .chevron { transform: rotate(180deg); }
.review-body { padding: 4px 18px 20px; border-top: 1px solid var(--line); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 15px 18px; margin-top: 16px; }
.field { min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field label, .field-label { display: block; margin-bottom: 6px; color: var(--muted); font-size: .86rem; font-weight: 760; }
.field select, .field input, .field textarea, .comment-card textarea, .dialog-card textarea { width: 100%; min-height: 48px; padding: 11px 12px; border: 1px solid #b9c7cf; border-radius: 9px; background: white; color: var(--ink); }
.field textarea, .comment-card textarea, .dialog-card textarea { resize: vertical; line-height: 1.48; }
.field-pair { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }

.choice-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; }
.choice { display: flex; align-items: flex-start; gap: 9px; min-height: 45px; margin: 0; padding: 10px 11px; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); background: #fbfdfe; font-size: .88rem; font-weight: 650; cursor: pointer; }
.choice input { flex: 0 0 auto; width: 19px; height: 19px; margin: 1px 0 0; accent-color: var(--blue); }
.choice:has(input:checked) { border-color: var(--blue); background: var(--blue-soft); }

.competency-section { margin-top: 18px; padding: 15px; border-radius: 11px; background: #f5f8fa; }
.competency-section .field-label { margin-bottom: 10px; color: var(--navy); }
.suggestion-row { display: grid; grid-template-columns: minmax(230px, .8fr) minmax(0, 1.2fr); gap: 16px; align-items: start; }
.related-choices { display: flex; flex-wrap: wrap; gap: 8px; }
.related-choice { display: flex; align-items: center; gap: 7px; min-height: 40px; margin: 0; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: white; color: var(--ink); font-size: .82rem; font-weight: 680; cursor: pointer; }
.related-choice input { width: 18px; height: 18px; margin: 0; accent-color: var(--blue); }
.related-choice:has(input:checked) { border-color: var(--blue); background: var(--blue-soft); }

.text-preview { margin-top: 16px; padding: 14px 15px; border-left: 4px solid var(--amber); border-radius: 8px; background: #fffaf0; }
.text-preview span { display: block; margin-bottom: 4px; color: #7a5b09; font-size: .74rem; font-weight: 850; letter-spacing: .08em; }
.text-preview p { margin: 0; }
.review-card-actions { display: flex; justify-content: flex-end; margin-top: 14px; }

.sticky-actions { position: sticky; bottom: 0; z-index: 5; display: flex; justify-content: flex-end; gap: 12px; margin-top: 22px; padding: 14px 0 calc(14px + env(safe-area-inset-bottom)); background: linear-gradient(to bottom, rgba(243,246,248,0), var(--canvas) 22%); }

.comment-card { padding: 18px; }
.comment-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.comment-heading h3 { margin: 0; color: var(--navy); font-size: 1.05rem; }
.comment-heading p { margin: 3px 0 0; color: var(--muted); font-size: .82rem; }
.copy-button { min-height: 43px; padding: 0 15px; border: 1px solid var(--blue); border-radius: 9px; background: var(--blue); color: white; font-weight: 820; cursor: pointer; }
.comment-card textarea { min-height: 116px; }
.comment-footer { display: flex; justify-content: space-between; gap: 12px; margin-top: 8px; color: var(--muted); font-size: .78rem; }
.link-button { padding: 0; border: 0; background: transparent; color: var(--blue); font-weight: 760; cursor: pointer; }

.history-card { display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 16px; padding: 17px 18px; }
.history-date { min-width: 110px; color: var(--navy); font-weight: 820; }
.history-copy strong, .history-copy small { display: block; }
.history-copy small { margin-top: 3px; color: var(--muted); }
.history-actions { display: flex; gap: 8px; }
.history-actions button { min-height: 42px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: white; color: var(--navy); font-weight: 760; cursor: pointer; }
.history-actions .delete-history { color: var(--red); }

.dialog-card { width: min(620px, calc(100vw - 30px)); padding: 0; border: 0; border-radius: 16px; box-shadow: 0 24px 70px rgba(4,27,40,.32); }
.dialog-card::backdrop { background: rgba(4,27,40,.58); backdrop-filter: blur(2px); }
.dialog-card form { padding: 22px; }
.dialog-heading { display: flex; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.dialog-card label { margin-top: 15px; }
.dialog-card select { width: 100%; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.icon-button { display: grid; place-items: center; width: 42px; height: 42px; border: 0; border-radius: 9px; background: #eef3f5; color: var(--navy); font-size: 1.5rem; cursor: pointer; }

@media (max-width: 900px) {
  .header-meta { align-items: flex-end; flex-direction: column; gap: 7px; }
  .review-summary { grid-template-columns: auto minmax(0,1fr) auto; }
  .competency-pill { grid-column: 2; max-width: none; justify-self: start; }
  .suggestion-row { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
  .header-meta { align-items: flex-start; }
  .page-heading { align-items: stretch; flex-direction: column; }
  .fit-button { width: 100%; }
  .form-grid, .choice-grid, .field-pair { grid-template-columns: 1fr; }
  .review-summary { grid-template-columns: auto minmax(0,1fr) auto; gap: 9px; }
  .competency-pill { grid-column: 1 / -1; }
  .history-card { grid-template-columns: 1fr; }
  .history-actions { width: 100%; }
  .history-actions button { flex: 1; }
  .sticky-actions { flex-direction: column-reverse; }
  .sticky-actions > * { width: 100%; }
}
