:root {
  color-scheme: light;
  --bg: #f6ead8;
  --surface: #fffaf1;
  --surface-strong: #ffffff;
  --ink: #243025;
  --muted: #6f6a57;
  --line: #decfb7;
  --forest: #2f6048;
  --forest-2: #42795d;
  --pine: #174432;
  --water: #327f8f;
  --sky: #8fc4cf;
  --sun: #f2a43a;
  --ember: #d86d37;
  --canvas: #f9dfb7;
  --berry: #a94d4b;
  --focus: #277784;
  --shadow: 0 18px 45px rgba(75, 57, 31, 0.14);
  --radius: 8px;
  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:
    radial-gradient(circle at 18px 18px, rgba(47, 96, 72, 0.08) 0 2px, transparent 2px),
    linear-gradient(135deg, rgba(50, 127, 143, 0.18), transparent 38%),
    linear-gradient(315deg, rgba(216, 109, 55, 0.18), transparent 34%),
    var(--bg);
  background-size: 38px 38px, auto, auto, auto;
  color: var(--ink);
}

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

button {
  cursor: pointer;
}

a {
  color: var(--water);
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  background:
    linear-gradient(180deg, rgba(255, 250, 241, 0.95), rgba(250, 236, 213, 0.9)),
    var(--surface);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 30px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--forest), var(--water));
  color: white;
  box-shadow: 0 10px 22px rgba(47, 96, 72, 0.24);
}

.brand-mark svg {
  width: 30px;
  height: 30px;
}

.brand strong,
.brand span {
  display: block;
}

.brand span,
.eyebrow,
.panel-title span {
  color: var(--muted);
  font-size: 0.82rem;
}

.tabs {
  display: grid;
  gap: 8px;
}

.tab {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid rgba(222, 207, 183, 0.2);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.34);
  color: var(--muted);
  text-align: left;
  font-weight: 750;
}

.tab:hover,
.tab.is-active {
  background: #eef6ec;
  border-color: #bdd8c1;
  color: var(--pine);
  box-shadow: 0 8px 18px rgba(47, 96, 72, 0.12);
}

.content {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 26px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  padding: 18px;
  border: 1px solid rgba(222, 207, 183, 0.78);
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, rgba(255, 250, 241, 0.92), rgba(255, 250, 241, 0.54)),
    var(--surface);
  box-shadow: var(--shadow);
}

.topbar > div:first-child {
  flex: 1 1 420px;
}

.eyebrow {
  margin: 0 0 6px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
  color: var(--ember);
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.15;
}

h1 {
  font-size: clamp(2.1rem, 3.4vw, 4rem);
}

h2 {
  font-size: 1.55rem;
}

h3 {
  font-size: 1rem;
}

.connection-status {
  display: grid;
  gap: 3px;
  width: fit-content;
  max-width: min(460px, 100%);
  margin-top: 12px;
  padding: 9px 12px;
  border: 1px solid rgba(222, 207, 183, 0.72);
  border-radius: var(--radius);
  background: rgba(255, 250, 241, 0.74);
  color: var(--muted);
}

.connection-status.is-online {
  border-color: #b9d9bd;
  background: rgba(238, 248, 237, 0.84);
  color: var(--forest);
}

.connection-status.is-error {
  border-color: #edc39c;
  background: rgba(255, 240, 223, 0.86);
  color: #8a5413;
}

.connection-status.is-local {
  border-color: #dfc78d;
  background: rgba(255, 247, 223, 0.86);
  color: #7a4c08;
}

.sync-status {
  font-size: 0.86rem;
  font-weight: 850;
}

.sync-status::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 999px;
  background: currentColor;
}

.sync-status-detail {
  color: color-mix(in srgb, currentColor 82%, var(--muted));
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.35;
}

.sync-status-detail:empty {
  display: none;
}

.app-runtime-status {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 650;
  opacity: 0.82;
}

.app-runtime-status.is-error,
.fatal-message {
  color: #8a2d16;
}

.fatal-message {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 50;
  max-width: 420px;
  padding: 12px 14px;
  border: 1px solid #efc9b8;
  border-radius: var(--radius);
  background: #fff0df;
  box-shadow: var(--shadow);
  font-weight: 800;
}

.pin-form {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) auto;
  gap: 8px;
  margin-top: 10px;
  max-width: 320px;
}

.pin-form[hidden] {
  display: none;
}

.pin-form button {
  min-height: 40px;
  border: 0;
  border-radius: var(--radius);
  background: var(--forest);
  color: white;
  padding: 0 12px;
  font-weight: 800;
}

.primary-action,
.secondary-action,
.entry-form button,
.ai-search-form button,
.data-actions button,
.file-button,
.quick-grid button {
  min-height: 42px;
  border: 0;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--forest), var(--pine));
  color: white;
  padding: 0 16px;
  font-weight: 700;
}

.secondary-action,
.data-actions button,
.file-button,
.quick-grid button {
  background: var(--surface-strong);
  color: var(--forest);
  border: 1px solid var(--line);
}

.secondary-action.compact {
  min-height: 34px;
  padding: 0 12px;
}

.primary-action:hover,
.entry-form button:hover {
  background: linear-gradient(135deg, var(--forest-2), var(--forest));
}

.camp-scene {
  flex: 0 1 320px;
  max-width: 340px;
  min-width: 220px;
  align-self: center;
  display: grid;
  place-items: center;
  border: 1px solid rgba(222, 207, 183, 0.7);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #d9edf0, #fbefd9);
  overflow: hidden;
}

.camp-scene svg {
  width: 100%;
  height: 112px;
  display: block;
}

.scene-sky {
  fill: #d8eff2;
}

.scene-sun {
  fill: var(--sun);
}

.scene-hill.back {
  fill: #93b795;
}

.scene-hill.front {
  fill: #5c956e;
}

.scene-ground {
  fill: #d9bd8b;
}

.scene-tree {
  fill: var(--pine);
}

.scene-van {
  fill: #f7eee0;
  stroke: var(--pine);
  stroke-width: 5;
  stroke-linejoin: round;
}

.scene-window {
  fill: var(--sky);
  stroke: var(--pine);
  stroke-width: 4;
}

.scene-door {
  fill: var(--canvas);
  stroke: var(--pine);
  stroke-width: 3;
}

.scene-wheel {
  fill: var(--pine);
  stroke: #f7eee0;
  stroke-width: 4;
}

.scene-fire {
  fill: var(--ember);
}

.trip-strip,
.entry-form,
.ai-search-form,
.toolbar,
.data-actions {
  display: grid;
  gap: 12px;
  padding: 14px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 250, 241, 0.82);
  box-shadow: 0 10px 28px rgba(75, 57, 31, 0.08);
}

.trip-strip {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: start;
}

.trip-strip > label,
.trip-strip > .field-block {
  align-self: start;
}

.date-range-field {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 8px;
}

.calendar-toggle {
  display: grid;
  place-items: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
  color: var(--forest);
}

.calendar-toggle svg {
  width: 21px;
  height: 21px;
}

.calendar-popover {
  position: absolute;
  z-index: 20;
  top: calc(100% + 8px);
  left: 0;
  width: min(690px, calc(100vw - 64px));
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}

.calendar-top,
.calendar-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.calendar-top {
  margin-bottom: 10px;
}

.calendar-selection {
  min-height: 24px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.88rem;
}

.calendar-manual {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.calendar-months {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.calendar-month {
  display: grid;
  gap: 8px;
}

.calendar-month h3 {
  font-size: 0.95rem;
  color: var(--forest);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}

.calendar-weekday,
.calendar-day {
  display: grid;
  place-items: center;
  min-height: 34px;
  border-radius: var(--radius);
}

.calendar-weekday {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}

.calendar-day {
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  padding: 0;
  font-weight: 700;
}

.calendar-day:hover {
  border-color: #c9d9cc;
  background: #edf4ee;
}

.calendar-day.is-outside {
  color: #b0aa9f;
}

.calendar-day.is-in-range {
  background: #e8f1f6;
  color: var(--forest);
}

.calendar-day.is-start,
.calendar-day.is-end {
  background: var(--forest);
  color: white;
}

.calendar-actions {
  margin-top: 12px;
}

.calendar-actions button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
  color: var(--forest);
  padding: 0 10px;
  font-weight: 700;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.field-block {
  display: grid;
  gap: 7px;
}

.field-label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.date-field-block {
  align-content: start;
}

input,
textarea,
select {
  width: 100%;
  min-width: 0;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffdf8;
  color: var(--ink);
  padding: 10px 11px;
}

textarea {
  height: auto;
  min-height: 86px;
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus,
button:focus-visible {
  outline: 3px solid rgba(13, 110, 120, 0.24);
  outline-offset: 2px;
}

.panel {
  display: none;
}

.panel.is-visible {
  display: block;
}

.section-heading,
.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric,
.workspace-panel,
.idea-card,
.place-card,
.task-row,
.phase-note,
.decision-place {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.74), rgba(255, 250, 241, 0.94)),
    var(--surface);
  box-shadow: var(--shadow);
}

.metric {
  padding: 16px;
  position: relative;
  overflow: hidden;
}

.metric::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  width: 88px;
  height: 34px;
  background: repeating-linear-gradient(
    135deg,
    rgba(242, 164, 58, 0.22) 0 8px,
    rgba(216, 109, 55, 0.12) 8px 16px
  );
  clip-path: polygon(30% 0, 100% 0, 100% 100%, 0 100%);
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 2rem;
  color: var(--pine);
}

.overview-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.workspace-panel,
.phase-note {
  padding: 16px;
}

.list-stack,
.card-grid,
.place-list,
.task-list,
.decision-matrix {
  display: grid;
  gap: 12px;
}

.card-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.info-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.info-intro {
  grid-column: 1 / -1;
}

.info-layout p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.info-steps,
.info-list {
  margin: 10px 0 0;
  padding-left: 1.25rem;
  color: var(--muted);
  line-height: 1.55;
}

.info-highlight {
  display: inline-flex;
  align-items: center;
  padding: 7px 10px;
  border: 1px solid #b9d9bd;
  border-radius: var(--radius);
  background: rgba(238, 248, 237, 0.84);
  color: var(--forest) !important;
  font-weight: 850;
}

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

.entry-form.is-open {
  display: grid;
}

.entry-form.large {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.entry-form textarea,
.entry-form button {
  grid-column: 1 / -1;
}

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

.ai-search-form label:first-child {
  grid-column: 1 / -1;
}

.ai-search-form button {
  grid-column: 1 / -1;
}

.ai-result-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(360px, 1.1fr);
  gap: 16px;
  margin-bottom: 18px;
}

.query-list {
  display: grid;
  gap: 10px;
}

.query-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f3f8ef;
}

.query-card span {
  overflow-wrap: anywhere;
}

.query-card a {
  font-weight: 800;
  white-space: nowrap;
}

.prompt-output {
  min-height: 360px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  line-height: 1.45;
}

.toolbar {
  grid-template-columns: repeat(2, minmax(0, 220px));
  justify-content: end;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-bottom: 12px;
}

.inline-form button {
  min-height: 42px;
  border: 0;
  border-radius: var(--radius);
  background: var(--forest);
  color: white;
  padding: 0 14px;
  font-weight: 700;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.person-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 6px 0 10px;
  border-radius: 999px;
  background: #eef6ec;
  color: var(--forest);
  font-size: 0.86rem;
  font-weight: 800;
}

.person-chip button {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 999px;
  background: #fffaf1;
  color: var(--forest);
  padding: 0;
  font-weight: 800;
}

.idea-card,
.place-card,
.task-row,
.decision-place {
  padding: 14px;
  border-top: 4px solid rgba(47, 96, 72, 0.35);
}

.place-card {
  border-top-color: rgba(50, 127, 143, 0.5);
}

.idea-card {
  border-top-color: rgba(242, 164, 58, 0.62);
}

.idea-card header,
.place-card header,
.task-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.meta-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: #eef6ec;
  color: var(--forest);
  font-size: 0.78rem;
  font-weight: 800;
}

.badge.warn {
  background: #fff1d6;
  color: #8a5413;
}

.badge.done {
  background: #e5f3f5;
  color: var(--water);
}

.score {
  display: inline-grid;
  place-items: center;
  min-width: 54px;
  height: 42px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--water), var(--forest));
  color: white;
  font-weight: 800;
}

.place-actions,
.item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.place-actions button,
.item-actions button,
.icon-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffdf8;
  color: var(--forest);
  padding: 0 10px;
  font-weight: 700;
}

.range-label {
  color: var(--muted);
}

input[type="range"] {
  padding: 0;
  accent-color: var(--forest);
}

.vote-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.vote {
  padding: 10px;
  border-left: 4px solid var(--water);
  background: #edf7f7;
  border-radius: var(--radius);
}

.task-row.is-done {
  opacity: 0.68;
}

.task-row.is-done h3 {
  text-decoration: line-through;
}

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

.file-button {
  display: grid;
  place-items: center;
}

.compact-file {
  min-height: 34px;
  padding: 0 12px;
  white-space: nowrap;
}

.file-button input {
  display: none;
}

.research-documents {
  margin-bottom: 18px;
}

.research-doc-list {
  display: grid;
  gap: 10px;
}

.research-doc-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fffdf8;
}

.research-doc-card h3 {
  overflow-wrap: anywhere;
}

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

.empty-state strong,
.empty-state span {
  display: block;
}

dialog {
  width: min(430px, calc(100% - 32px));
  border: 0;
  border-radius: var(--radius);
  padding: 0;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(31, 41, 35, 0.42);
}

.dialog-content {
  padding: 18px;
}

.quick-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding: 14px;
  }

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

  .tab {
    text-align: center;
  }

  .content {
    padding: 18px 14px 28px;
  }

  .trip-strip,
  .metric-grid,
  .overview-grid,
  .info-layout,
  .entry-form,
  .entry-form.large,
  .ai-search-form,
  .ai-result-grid,
  .calendar-manual,
  .toolbar,
  .data-actions {
    grid-template-columns: 1fr;
  }

  .topbar,
  .section-heading,
  .idea-card header,
  .place-card header,
  .task-row,
  .research-doc-card {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar > div:first-child {
    flex: 0 1 auto;
    width: 100%;
  }

  .camp-scene {
    flex: none;
    max-width: none;
    min-width: 0;
    width: 100%;
  }

  .camp-scene svg {
    height: 110px;
  }

  .calendar-popover {
    position: fixed;
    top: 96px;
    left: 14px;
    right: 14px;
    width: auto;
    max-height: calc(100vh - 120px);
    overflow: auto;
  }

  .calendar-months {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  body {
    background:
      linear-gradient(180deg, rgba(255, 250, 241, 0.82), rgba(246, 234, 216, 0.94)),
      var(--bg);
  }

  .sidebar {
    padding: 10px 12px 8px;
  }

  .brand {
    gap: 10px;
    margin-bottom: 12px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
  }

  .brand-mark svg {
    width: 24px;
    height: 24px;
  }

  .brand strong {
    font-size: 0.96rem;
  }

  .brand span {
    font-size: 0.76rem;
  }

  .tabs {
    display: flex;
    gap: 8px;
    margin: 0 -12px;
    padding: 0 12px 4px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .tabs::-webkit-scrollbar {
    display: none;
  }

  .tab {
    flex: 0 0 auto;
    width: auto;
    min-width: 98px;
    min-height: 40px;
    padding: 9px 12px;
    white-space: nowrap;
  }

  .content {
    padding: 10px 12px 24px;
  }

  .topbar {
    gap: 12px;
    margin-bottom: 14px;
    padding: 12px;
  }

  .camp-scene {
    display: none;
  }

  .eyebrow {
    margin-bottom: 4px;
    font-size: 0.72rem;
  }

  h1 {
    max-width: 12ch;
    font-size: 1.78rem;
    line-height: 1.05;
  }

  .connection-status {
    width: 100%;
    margin-top: 8px;
    padding: 7px 9px;
  }

  .pin-form {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px;
    margin-top: 8px;
    max-width: none;
  }

  .app-runtime-status {
    display: none;
  }
}

@media (max-width: 520px) {
  .quick-grid {
    grid-template-columns: 1fr 1fr;
  }

  h1 {
    font-size: 1.68rem;
  }
}
