:root {
  color-scheme: light;
  --bg: #f6f7f3;
  --surface: #ffffff;
  --ink: #20252b;
  --muted: #66707b;
  --line: #dfe4df;
  --accent: #e7563c;
  --accent-dark: #bd3f2b;
  --forest: #2d6a4f;
  --sky: #2f6f9f;
  --gold: #b7791f;
  --shadow: 0 18px 45px rgba(31, 37, 43, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    "Inter", "Pretendard", "Apple SD Gothic Neo", "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 28px 22px;
  background: #1f2a2d;
  color: #f9fbf6;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

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

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.brand h1,
.brand p {
  margin: 0;
}

.brand h1 {
  font-size: 18px;
}

.brand p {
  margin-top: 3px;
  color: #b8c3be;
  font-size: 13px;
}

.app-version {
  display: inline-block;
  margin-top: 4px;
  color: #f7b0a3;
  font-size: 12px;
  font-weight: 850;
}

.side-nav {
  display: grid;
  gap: 8px;
}

.side-nav a {
  color: #dfe8e4;
  text-decoration: none;
  padding: 11px 12px;
  border-radius: 8px;
  font-size: 14px;
}

.side-nav a.active,
.side-nav a:hover {
  background: rgba(255, 255, 255, 0.11);
  color: #fff;
}

.status-panel {
  margin-top: auto;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  display: grid;
  gap: 8px;
}

.status-label,
.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.status-panel strong {
  font-size: 16px;
}

.status-panel small {
  color: #c8d1cd;
  line-height: 1.45;
}

.workspace {
  padding: 30px;
  display: grid;
  gap: 22px;
  align-content: start;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.topbar h2 {
  max-width: 760px;
  margin: 5px 0 0;
  font-size: 36px;
  line-height: 1.14;
}

.eyebrow {
  margin: 0;
}

.actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.primary-button,
.secondary-button,
.text-button,
.icon-button {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 15px;
  font-weight: 750;
  white-space: nowrap;
}

.primary-button {
  background: var(--accent);
  color: #fff;
}

.primary-button:hover {
  background: var(--accent-dark);
}

.secondary-button {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

.secondary-button:hover,
.icon-button:hover {
  border-color: #b9c3bd;
}

.text-button {
  background: transparent;
  color: var(--muted);
  padding-inline: 8px;
}

.icon-button {
  width: 42px;
  padding: 0;
  background: #fff;
  border-color: var(--line);
  font-size: 18px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 22px;
}

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

.section-heading.compact {
  margin-bottom: 10px;
}

.section-heading h3 {
  margin: 4px 0 0;
  font-size: 20px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: #48515a;
  font-size: 13px;
  font-weight: 750;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cfd7d1;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

input,
select {
  min-height: 42px;
  padding: 0 12px;
}

textarea {
  min-height: 170px;
  padding: 12px;
  resize: vertical;
  line-height: 1.55;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  outline: 3px solid rgba(47, 111, 159, 0.22);
  outline-offset: 2px;
}

.ai-panel {
  border-color: #cbded6;
}

.wide-label {
  font-size: 14px;
}

.ai-tools {
  display: grid;
  grid-template-columns: minmax(180px, 260px) max-content;
  align-items: end;
  gap: 12px;
  margin-top: 14px;
}

.ai-status {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

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

.server-guide {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid #f1c5bd;
  border-radius: 8px;
  background: #fff7f5;
  color: #3b2b28;
  display: grid;
  gap: 5px;
  line-height: 1.5;
}

.server-guide code {
  font-weight: 850;
}

.optional-panel summary {
  cursor: pointer;
  font-weight: 850;
  color: var(--muted);
}

.optional-panel[open] summary {
  margin-bottom: 18px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.ai-status.loading {
  color: var(--sky);
}

.ai-status.ready {
  color: var(--forest);
}

.ai-status.error {
  color: var(--accent-dark);
}

.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
  border: 0;
  margin: 18px 0 0;
  padding: 0;
}

.segmented legend {
  width: 100%;
  margin-bottom: 8px;
  color: #48515a;
  font-size: 13px;
  font-weight: 750;
}

.segmented label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
}

.segmented input {
  width: auto;
  min-height: auto;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}

th {
  text-align: left;
  color: var(--muted);
  font-size: 12px;
  padding: 0 8px 8px;
}

td {
  padding: 8px;
  border-top: 1px solid #edf0ec;
  vertical-align: top;
}

td input,
td select {
  min-height: 38px;
}

.small-cell {
  width: 98px;
}

.delete-row {
  width: 38px;
  height: 38px;
  border: 1px solid #f0c8bf;
  border-radius: 8px;
  background: #fff8f6;
  color: var(--accent-dark);
  font-size: 18px;
}

.schedule-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 430px;
  gap: 22px;
}

.schedule-output {
  display: grid;
  gap: 16px;
}

.empty-state {
  min-height: 180px;
  place-items: center;
  border: 1px dashed #cdd7d0;
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.day-block {
  border: 1px solid #e2e8e2;
  border-radius: 8px;
  overflow: hidden;
}

.day-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: #f8faf5;
  border-bottom: 1px solid #e2e8e2;
}

.day-title h4 {
  margin: 0;
  font-size: 17px;
}

.day-title span {
  color: var(--muted);
  font-size: 13px;
}

.timeline {
  display: grid;
}

.timeline-item {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 14px;
  padding: 14px 16px;
  border-top: 1px solid #edf0ec;
}

.timeline-item:first-child {
  border-top: 0;
}

.time-range {
  color: var(--sky);
  font-weight: 850;
  font-size: 14px;
}

.item-card {
  display: grid;
  gap: 5px;
}

.item-card strong {
  font-size: 16px;
}

.item-meta {
  color: var(--muted);
  font-size: 13px;
}

.badge {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.badge.fixed {
  background: #eaf4ef;
  color: var(--forest);
}

.badge.place {
  background: #fff2ea;
  color: var(--gold);
}

.right-rail {
  display: grid;
  gap: 22px;
  align-self: start;
  position: sticky;
  top: 22px;
}

.map-panel,
.reminders-panel {
  align-self: start;
}

.map-controls {
  display: grid;
  grid-template-columns: 1fr 130px;
  gap: 10px;
  margin-bottom: 12px;
}

.map-frame-wrap {
  position: relative;
  min-height: 340px;
  border: 1px solid #e2e8e2;
  border-radius: 8px;
  overflow: hidden;
  background: #f8faf5;
}

.map-frame-wrap iframe {
  width: 100%;
  height: 340px;
  border: 0;
  display: block;
}

.route-map {
  min-height: 340px;
  background: #edf5f4;
}

.route-map svg {
  width: 100%;
  height: 300px;
  display: block;
}

.route-water {
  fill: #dceeed;
}

.route-land {
  fill: #f8faf5;
}

.route-road {
  fill: none;
  stroke: #d3d9d3;
  stroke-width: 15;
  stroke-linecap: round;
}

.route-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 8 8;
}

.route-pin circle {
  fill: #1f2a2d;
  stroke: #fff;
  stroke-width: 4;
}

.route-pin text {
  fill: #fff;
  font-size: 14px;
  font-weight: 850;
  text-anchor: middle;
}

.route-map-caption {
  padding: 0 14px 14px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.map-empty {
  min-height: 340px;
  display: grid;
  place-items: center;
  padding: 24px;
  color: var(--muted);
  text-align: center;
  line-height: 1.5;
}

.map-link {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  min-height: 40px;
  margin-top: 12px;
  border-radius: 8px;
  background: #1f2a2d;
  color: #fff;
  text-decoration: none;
  font-weight: 800;
}

.map-route-summary {
  display: grid;
  gap: 6px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.map-route-summary span {
  display: block;
  padding: 7px 8px;
  border: 1px solid #e2e8e2;
  border-radius: 8px;
  background: #f8faf5;
}

.map-link[hidden] {
  display: none;
}

.map-hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

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

.reminder-card {
  border: 1px solid #e2e8e2;
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 5px;
}

.reminder-card strong {
  font-size: 14px;
}

.reminder-card small {
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: min(420px, calc(100vw - 44px));
  padding: 13px 15px;
  border-radius: 8px;
  background: #1f2a2d;
  color: #fff;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
  box-shadow: var(--shadow);
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

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

  .sidebar {
    position: static;
    height: auto;
  }

  .side-nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .schedule-layout {
    grid-template-columns: 1fr;
  }

  .right-rail {
    position: static;
  }
}

@media (max-width: 760px) {
  .workspace {
    padding: 18px;
  }

  .topbar,
  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar h2 {
    font-size: 26px;
  }

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

  .form-grid {
    grid-template-columns: 1fr;
  }

  .ai-tools {
    grid-template-columns: 1fr;
  }

  .side-nav {
    grid-template-columns: 1fr 1fr;
  }

  .timeline-item {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .map-controls {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  body {
    font-size: 17px;
  }

  .app-shell {
    display: block;
  }

  .sidebar {
    padding: 14px 16px;
    gap: 12px;
  }

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

  .brand h1 {
    font-size: 17px;
  }

  .status-panel,
  .side-nav {
    display: none;
  }

  .brand p {
    display: none;
  }

  .app-version {
    display: inline-block;
    font-size: 12px;
  }

  .workspace {
    padding: 16px 12px 28px;
    gap: 16px;
  }

  .topbar {
    gap: 14px;
  }

  .topbar h2 {
    max-width: 100%;
    font-size: 28px;
    line-height: 1.13;
  }

  .eyebrow {
    font-size: 12px;
  }

  .actions {
    display: grid;
    grid-template-columns: 48px 1fr;
    gap: 9px;
    width: 100%;
  }

  .actions .secondary-button {
    grid-column: 1 / -1;
  }

  .actions .primary-button {
    grid-column: 2;
  }

  .primary-button,
  .secondary-button,
  .text-button,
  .icon-button {
    min-height: 48px;
    padding: 0 14px;
    font-size: 16px;
  }

  .icon-button {
    width: 48px;
  }

  .panel {
    padding: 18px;
    border-radius: 8px;
    box-shadow: 0 10px 26px rgba(31, 37, 43, 0.06);
  }

  .section-heading {
    gap: 8px;
    margin-bottom: 14px;
  }

  .section-heading h3 {
    font-size: 21px;
  }

  label {
    font-size: 14px;
  }

  input,
  select {
    min-height: 50px;
    font-size: 16px;
  }

  textarea {
    min-height: 250px;
    font-size: 16px;
    line-height: 1.6;
  }

  .helper-text,
  .ai-status,
  .map-hint,
  .route-map-caption {
    font-size: 13px;
  }

  .ai-tools {
    gap: 10px;
  }

  .optional-panel,
  #places-section,
  #fixed-section {
    display: none;
  }

  .schedule-layout {
    gap: 16px;
  }

  .day-title {
    align-items: flex-start;
    flex-direction: column;
    padding: 14px;
  }

  .day-title h4 {
    font-size: 19px;
  }

  .timeline-item {
    padding: 15px 14px;
  }

  .time-range {
    font-size: 16px;
  }

  .item-card strong {
    font-size: 17px;
  }

  .item-meta {
    font-size: 14px;
    line-height: 1.45;
  }

  .right-rail {
    gap: 16px;
  }

  .map-controls {
    grid-template-columns: 1fr 120px;
  }

  .map-frame-wrap,
  .route-map,
  .map-empty {
    min-height: 300px;
  }

  .route-map svg {
    height: 258px;
  }

  .map-link {
    min-height: 48px;
    font-size: 16px;
  }

  .map-route-summary {
    font-size: 13px;
  }

  .map-route-summary span {
    padding: 10px;
  }

  .reminders-panel {
    display: none;
  }

  .toast {
    right: 12px;
    bottom: 12px;
    max-width: calc(100vw - 24px);
    font-size: 14px;
  }
}
