:root {
  color-scheme: light;
  --ink: #172022;
  --muted: #667277;
  --line: #dbe3e5;
  --surface: #f7f9f8;
  --panel: #ffffff;
  --accent: #187a8a;
  --accent-strong: #0f5d69;
  --soft-accent: #e3f2f4;
  --soft-accent-dark: #0a3137;
  --soft-accent-glow: rgba(24, 122, 138, 0.18);
  --danger: #b94343;
  --shadow: 0 18px 45px rgba(30, 47, 52, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, var(--soft-accent-glow), transparent 28rem),
    linear-gradient(135deg, #f7faf9 0%, #eef4f1 45%, #f8f7f1 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body[data-theme="dark"] {
  --ink: #f5f8f8;
  --muted: #9ca9ad;
  --line: #2d383b;
  --surface: #151a1c;
  --panel: #0d1112;
  --danger: #ff8d8d;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.36);
  background:
    radial-gradient(circle at top left, var(--soft-accent-glow), transparent 30rem),
    linear-gradient(135deg, #050606 0%, #0d1112 52%, #000000 100%);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.trip-sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px;
  background: rgba(255, 255, 255, 0.74);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

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

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: white;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  border-radius: 8px;
  font-weight: 800;
}

.brand p,
.brand span,
.eyebrow,
.section-heading h1 {
  margin: 0;
}

.brand p {
  font-weight: 800;
}

.brand span,
.eyebrow {
  color: var(--muted);
  font-size: 12px;
}

.primary-action,
.secondary-action,
.danger-action,
.icon-button,
.tab,
.inline-form button {
  border: 0;
  border-radius: 8px;
  min-height: 40px;
  font-weight: 700;
}

.primary-action {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  color: white;
  background: var(--accent);
}

.primary-action:hover {
  background: var(--accent-strong);
}

.secondary-action {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  color: var(--accent-strong);
  background: var(--soft-accent);
}

.danger-action {
  padding: 0 14px;
  color: var(--danger);
  background: #fdeaea;
}

.icon-button {
  width: 42px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
}

.trip-list {
  display: grid;
  gap: 8px;
}

.trip-list-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px;
  gap: 6px;
  align-items: stretch;
  border: 1px solid transparent;
  border-radius: 8px;
}

.trip-list-item.is-active,
.trip-list-item:hover {
  background: var(--panel);
  border-color: var(--line);
}

.trip-select-button {
  width: 100%;
  padding: 12px;
  text-align: left;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-radius: 8px;
}

.trip-delete-button {
  width: 38px;
  min-height: 38px;
  align-self: center;
  color: var(--danger);
  background: transparent;
  border: 0;
  border-radius: 8px;
  font-size: 20px;
  font-weight: 800;
}

.trip-delete-button:hover {
  background: #fdeaea;
}

.trip-select-button strong,
.trip-select-button span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trip-select-button span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.workspace {
  min-width: 0;
  padding: 24px;
}

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

.topbar > div:first-child {
  min-width: 0;
  flex: 1;
}

.title-input {
  width: 100%;
  padding: 0;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: 0;
  font-size: clamp(28px, 4vw, 48px);
  font-weight: 850;
  line-height: 1.08;
}

.topbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.trip-meta {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

input[type="color"] {
  height: 42px;
  padding: 4px;
}

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

input,
textarea {
  width: 100%;
  min-width: 0;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}

input {
  height: 42px;
  padding: 0 12px;
}

textarea {
  resize: vertical;
  padding: 12px;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(24, 122, 138, 0.13);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 18px;
  align-items: start;
}

.schedule-panel,
.notes-panel {
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.schedule-panel {
  padding: 20px;
}

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

.section-heading h1 {
  font-size: 24px;
  letter-spacing: 0;
}

.timeline {
  display: grid;
  gap: 12px;
}

.day-tabs {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(104px, 1fr);
  gap: 8px;
  margin-bottom: 16px;
  overflow-x: auto;
}

.day-tabs[hidden] {
  display: none;
}

.day-tab {
  display: grid;
  gap: 2px;
  min-height: 54px;
  padding: 8px 12px;
  color: var(--muted);
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.day-tab strong {
  color: var(--ink);
  font-size: 14px;
}

.day-tab span {
  font-size: 12px;
}

.day-tab.is-active {
  color: white;
  background: var(--accent);
  border-color: var(--accent);
}

.day-tab.is-active strong,
.day-tab.is-active span {
  color: white;
}

.day-group {
  display: grid;
  gap: 10px;
}

.day-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-weight: 800;
}

.day-heading::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--line);
}

.event-card {
  display: grid;
  grid-template-columns: 94px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 5px solid var(--accent);
  border-radius: 8px;
}

.event-time {
  color: var(--accent-strong);
  font-weight: 850;
}

.event-card h3 {
  margin: 0 0 6px;
  font-size: 17px;
}

.event-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

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

.event-actions a,
.event-actions button,
.event-actions label {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  color: var(--ink);
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.empty-state {
  display: grid;
  min-height: 280px;
  place-items: center;
  padding: 24px;
  color: var(--muted);
  text-align: center;
  border: 1px dashed #bdcacc;
  border-radius: 8px;
}

.notes-panel {
  overflow: hidden;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 8px;
  gap: 8px;
  border-bottom: 1px solid var(--line);
}

.tab {
  color: var(--muted);
  background: transparent;
}

.tab.is-active {
  color: var(--accent-strong);
  background: var(--soft-accent);
}

.tab-panel {
  display: none;
  padding: 16px;
}

.tab-panel.is-active {
  display: grid;
  gap: 14px;
}

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

.quick-notes,
.image-board {
  display: grid;
  gap: 10px;
}

.quick-note {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.quick-note p {
  margin: 0;
  overflow-wrap: anywhere;
}

.quick-note button,
.image-item button {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  color: var(--danger);
  background: #fdeaea;
}

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

.inline-form button {
  color: white;
  background: var(--accent);
}

.upload-zone {
  display: grid;
  min-height: 136px;
  place-items: center;
  padding: 18px;
  text-align: center;
  color: var(--ink);
  background: var(--soft-accent);
  border: 1px dashed #abc0b3;
  border-radius: 8px;
}

body[data-theme="dark"] .upload-zone,
body[data-theme="dark"] .secondary-action,
body[data-theme="dark"] .tab.is-active {
  background: var(--soft-accent-dark);
}

body[data-theme="dark"] .trip-sidebar,
body[data-theme="dark"] .schedule-panel,
body[data-theme="dark"] .notes-panel,
body[data-theme="dark"] .event-form {
  background: rgba(13, 17, 18, 0.92);
}

body[data-theme="dark"] input,
body[data-theme="dark"] textarea,
body[data-theme="dark"] .event-card,
body[data-theme="dark"] .image-item,
body[data-theme="dark"] .trip-list-item.is-active,
body[data-theme="dark"] .trip-list-item:hover {
  background: #090c0d;
}

body[data-theme="dark"] .trip-delete-button:hover {
  background: rgba(255, 141, 141, 0.14);
}

.upload-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.upload-zone span {
  font-size: 16px;
  font-weight: 800;
}

.upload-zone small {
  color: var(--muted);
}

.image-item {
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.event-images {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(116px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.event-image-thumb {
  position: relative;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.event-image-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.event-image-thumb button {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  color: var(--danger);
  background: rgba(255, 255, 255, 0.9);
  border: 0;
  border-radius: 8px;
}

.event-image-upload input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.event-image-upload span {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 16px;
}

.image-item img {
  display: block;
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  background: #eef4f1;
}

.image-caption {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
}

.image-caption input {
  height: 36px;
}

.image-source {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

dialog {
  width: min(560px, calc(100vw - 28px));
  padding: 0;
  border: 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(23, 32, 34, 0.42);
}

.event-form {
  display: grid;
  gap: 14px;
  padding: 18px;
  background: var(--panel);
}

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

.dialog-header h2 {
  margin: 0;
}

.time-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.dialog-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.settings-section {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.settings-section h3 {
  margin: 2px 0 0;
  font-size: 18px;
}

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

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  min-height: 42px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.mode-button {
  min-height: 32px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 6px;
  font-weight: 800;
}

.mode-button.is-active {
  color: white;
  background: var(--accent);
}

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

  .trip-sidebar {
    position: sticky;
    top: 0;
    z-index: 2;
    display: grid;
    grid-template-columns: 1fr auto;
  }

  .trip-list {
    grid-column: 1 / -1;
    grid-auto-flow: column;
    grid-auto-columns: minmax(180px, 1fr);
    overflow-x: auto;
  }

  .content-grid,
  .trip-meta {
    grid-template-columns: 1fr 1fr;
  }

  .notes-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .workspace,
  .trip-sidebar {
    padding: 14px;
  }

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

  .topbar-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 42px;
    justify-content: stretch;
  }

  .trip-meta,
  .settings-grid,
  .content-grid,
  .event-card,
  .time-row {
    grid-template-columns: 1fr;
  }

  .event-card {
    gap: 8px;
  }

  .event-actions {
    justify-content: flex-end;
  }
}
