@import url("https://fonts.googleapis.com/css2?family=Bungee:wght@400&family=Manrope:wght@400;600;700;800&display=swap");

:root {
  --bg-1: #f7f2e8;
  --bg-2: #f0e7d2;
  --ink: #1f2024;
  --muted: #4f5563;
  --card: #fffaf0;
  --line: #d8c8ab;
  --accent: #146c78;
  --accent-2: #cb5f2f;
  --success: #2f7d45;
  --danger: #a22929;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.11);
}

.loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(247, 242, 232, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.loading-screen.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-spinner {
  text-align: center;
}

.spinner {
  border: 4px solid var(--line);
  border-top: 4px solid var(--accent);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading-spinner p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Manrope", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 5%, #fff6de 0%, transparent 35%),
    radial-gradient(circle at 90% 95%, #f6d6c7 0%, transparent 35%),
    linear-gradient(140deg, var(--bg-1), var(--bg-2));
  min-height: 100vh;
  padding: 1rem;
  overflow-x: hidden;
}

.bg-orb {
  position: fixed;
  border-radius: 999px;
  filter: blur(45px);
  opacity: 0.4;
  z-index: -1;
}

.orb-a {
  width: 240px;
  height: 240px;
  background: #ffd575;
  top: -60px;
  right: -40px;
}

.orb-b {
  width: 260px;
  height: 260px;
  background: #7fd7c7;
  left: -70px;
  bottom: -80px;
}

h1, h2, h3 {
  margin: 0;
}

.app-header {
  margin: 0 auto 1rem;
  max-width: 1400px;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.app-header h1 {
  font-family: "Bungee", "Trebuchet MS", sans-serif;
  font-size: clamp(1.6rem, 2.6vw, 2.4rem);
  letter-spacing: 0.03em;
  margin: 0;
}

.help-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-size: 1.1rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: transform 150ms ease, filter 150ms ease;
}

.help-btn:hover {
  filter: brightness(1.1);
  transform: scale(1.05);
}

.app-header p {
  margin: 0.4rem 0 0;
  color: var(--muted);
}

.card {
  background: color-mix(in oklab, var(--card) 94%, white 6%);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.controls {
  max-width: 1400px;
  margin: 0 auto 1rem;
  padding: 1rem;
}

.controls h2 {
  margin-bottom: 0.7rem;
}

.controls-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.7rem;
}

.controls-header h2 {
  margin: 0;
}

.toggle-btn {
  font-size: 0.85rem;
  padding: 0.4rem 0.7rem;
  background: #486977;
  color: white;
}

.grid {
  display: grid;
  gap: 0.7rem;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.essential-filters {
  display: grid;
}

.advanced-filters {
  display: grid;
  margin-top: 0.5rem;
  padding-top: 0.7rem;
  border-top: 1px solid var(--line);
}

label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.9rem;
  color: var(--muted);
}

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

input, select, textarea {
  border-radius: 10px;
  border: 1px solid #d0c1a6;
  padding: 0.55rem 0.65rem;
  background: #fffcf4;
}

textarea {
  width: 100%;
}

.controls-row {
  margin-top: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  align-items: center;
}

.inline {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

button {
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  padding: 0.5rem 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 180ms ease, filter 180ms ease;
}

button:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

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

/* Theme & Duration Filter Buttons */
.theme-filter-buttons, .duration-filter-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.theme-btn, .duration-btn {
  padding: 0.4rem 0.7rem;
  font-size: 0.85rem;
  border-radius: 6px;
  background: var(--bg-2);
  color: var(--ink);
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 150ms ease;
  font-weight: 500;
}

.theme-btn:hover, .duration-btn:hover {
  background: var(--line);
  transform: translateY(-1px);
}

.theme-btn.active, .duration-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 700;
}

.timeline-section {
  max-width: 1400px;
  margin: 0 auto 1rem;
  padding: 1rem;
}

.layout {
  max-width: 1400px;
  margin: 0 auto;
  display: grid;
  gap: 1rem;
  grid-template-columns: 1.2fr 1fr;
}

.results, .itinerary {
  padding: 1rem;
  min-height: 500px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.7rem;
}

.actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.dropdown-menu {
  position: relative;
}

.menu-btn {
  background: #486977;
  font-size: 0.85rem;
  padding: 0.5rem 0.65rem;
}

.menu-content {
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  min-width: 180px;
  margin-top: 0.3rem;
}

.menu-content button {
  width: 100%;
  display: block;
  text-align: left;
  background: transparent;
  color: var(--ink);
  padding: 0.55rem 0.75rem;
  border: none;
  border-radius: 0;
  font-weight: 400;
  cursor: pointer;
  transition: background 150ms ease;
}

.menu-content button:first-child {
  border-radius: 10px 10px 0 0;
}

.menu-content button:last-child {
  border-radius: 0 0 10px 10px;
}

.menu-content button:hover {
  background: var(--bg-2);
  transform: none;
  filter: none;
}

#resultsMeta {
  color: var(--muted);
  font-size: 0.88rem;
}

.results-list {
  display: grid;
  gap: 0.65rem;
  max-height: 72vh;
  overflow: auto;
  padding-right: 0.2rem;
}

.event-card {
  border: 1px solid #e0cfb2;
  border-radius: 14px;
  padding: 0.75rem;
  background: linear-gradient(180deg, #fffef9, #fff6e8);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.7rem;
  animation: settle 450ms cubic-bezier(0.2, 0.8, 0.2, 1);
  cursor: pointer;
}

.event-card.conflict {
  border-color: #dc8f8f;
  background: linear-gradient(180deg, #fff6f6, #fff0f0);
}

.event-title {
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.event-meta, .event-sub {
  margin: 0.12rem 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.event-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
}

.badge {
  font-size: 0.75rem;
  background: #1e6f7b;
  color: #fff;
  border-radius: 999px;
  padding: 0.22rem 0.52rem;
}

.pick-btn {
  background: var(--accent-2);
}

.event-fit {
  margin: 0.2rem 0 0;
  font-size: 0.82rem;
  color: #2d5d19;
  font-weight: 700;
}

.event-conflict {
  margin: 0.15rem 0 0;
  font-size: 0.8rem;
  color: #a22929;
  font-weight: 700;
}

.timeline {
  display: grid;
  gap: 0.8rem;
}

.day-group {
  border: 1px solid #dccaae;
  border-radius: 12px;
  padding: 0.6rem;
  background: #fffef8;
}

.day-title {
  font-weight: 800;
  margin-bottom: 0.45rem;
}

.slot {
  border: 1px solid #e5d7c0;
  border-radius: 10px;
  padding: 0.5rem;
  margin-bottom: 0.5rem;
  display: grid;
  gap: 0.35rem;
  background: #fff8ed;
}

.slot.conflict {
  border-color: #c95050;
  background: #fff3f3;
}

.slot-head {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: center;
}

.slot-title {
  font-weight: 700;
}

.slot-meta {
  font-size: 0.84rem;
  color: var(--muted);
}

.remove-btn {
  background: #8f2c2c;
  padding: 0.35rem 0.65rem;
}

.empty {
  color: var(--muted);
  border: 1px dashed #c9b89a;
  border-radius: 10px;
  padding: 0.8rem;
}

.share-label {
  margin-top: 0.5rem;
}

#sharePreview {
  margin-top: 0.4rem;
  background: #fffdf7;
}

.conmode-grid {
  max-width: 1400px;
  margin: 1rem auto 0;
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
}

.conmode-grid.timeline-right #timelineVisualizerPanel {
  order: 2;
}

.conmode-grid.timeline-right #coPilotPanel {
  order: 1;
}

.conmode-panel {
  padding: 1rem;
}

.visualizer-controls {
  margin-top: -0.2rem;
  margin-bottom: 0.5rem;
}

.day-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.7rem;
}

.day-tab {
  background: #486977;
  font-size: 0.85rem;
}

.day-tab.active {
  background: #cb5f2f;
}

.timeline-grid {
  border: 1px solid #d9c7a6;
  border-radius: 14px;
  background: #fffcf4;
  padding: 0.5rem;
  min-height: 320px;
}

.week-grid {
  border: 1px solid #d9c7a6;
  border-radius: 12px;
  overflow: auto;
  background: #fffdf6;
}

.week-header {
  display: grid;
  position: sticky;
  top: 0;
  z-index: 2;
  background: #fff4de;
  border-bottom: 1px solid #e4d4b8;
}

.week-header > div {
  padding: 0.45rem;
  font-size: 0.8rem;
  font-weight: 800;
  border-left: 1px solid #ead9bc;
}

.week-header > div:first-child {
  border-left: 0;
}

.week-body {
  display: grid;
}

.week-time-col, .week-lane {
  position: relative;
}

.week-time-col {
  border-right: 1px solid #ead9bc;
}

.week-time-label {
  position: absolute;
  left: 6px;
  transform: translateY(-50%);
  font-size: 0.72rem;
  color: #7f7563;
}

.week-hour-line {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1px dashed #ecdcc1;
}

.week-lane {
  border-left: 1px solid #ead9bc;
}

.horizontal-day {
  border: 1px solid #dcc9a8;
  border-radius: 10px;
  background: #fffef8;
  overflow: auto;
}

.horizontal-axis {
  position: relative;
  min-height: 150px;
}

.h-hour-line {
  position: absolute;
  top: 0;
  bottom: 0;
  border-left: 1px dashed #ecdcc1;
}

.h-hour-label {
  position: absolute;
  top: 4px;
  transform: translateX(-50%);
  font-size: 0.72rem;
  color: #7f7563;
}

.h-event-lane {
  position: absolute;
  left: 0;
  right: 0;
  top: 30px;
  bottom: 8px;
}

.h-event-block {
  position: absolute;
  top: 8px;
  min-height: 74px;
  border-radius: 10px;
  padding: 0.38rem 0.45rem;
  color: #fff;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.14);
  overflow: hidden;
  cursor: pointer;
}

.h-event-block h4 {
  margin: 0;
  font-size: 0.82rem;
}

.h-event-block p {
  margin: 0.15rem 0 0;
  font-size: 0.72rem;
}

.h-event-block.conflict {
  outline: 2px solid #fff;
  border: 1px solid #611;
}

.week-h {
  border: 1px solid #d9c7a6;
  border-radius: 12px;
  overflow: auto;
  background: #fffdf6;
}

.week-h-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  border-top: 1px solid #ead9bc;
}

.week-h-row:first-child {
  border-top: 0;
}

.week-h-day {
  padding: 0.45rem;
  font-weight: 800;
  font-size: 0.82rem;
  background: #fff4de;
  border-right: 1px solid #ead9bc;
}

.week-h-row .horizontal-axis {
  min-height: 110px;
}

.time-row {
  position: relative;
  min-height: 46px;
  border-top: 1px dashed #ebdecb;
}

.time-row:first-child {
  border-top: 0;
}

.time-label {
  position: absolute;
  top: 2px;
  left: 4px;
  font-size: 0.74rem;
  color: #7f7563;
}

.event-block {
  position: absolute;
  left: 76px;
  right: 6px;
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 0.42rem 0.5rem;
  color: #fff;
  overflow: hidden;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.14);
  cursor: pointer;
}

.event-block h4 {
  margin: 0;
  font-size: 0.85rem;
}

.event-block p {
  margin: 0.15rem 0 0;
  font-size: 0.72rem;
  opacity: 0.93;
}

.event-block.conflict {
  outline: 2px solid #fff;
  border-color: #611;
}

.gap-note {
  margin-top: 0.6rem;
  border: 1px dashed #c9b596;
  border-radius: 10px;
  padding: 0.4rem 0.55rem;
  font-size: 0.82rem;
  color: #6f5f47;
}

.conflict-list {
  margin-top: 0.7rem;
  display: grid;
  gap: 0.35rem;
}

.conflict-item {
  border: 1px solid #da9a9a;
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  background: #fff2f2;
  font-size: 0.82rem;
}

.insights-list, .recommendations-list {
  display: grid;
  gap: 0.5rem;
}

.ai-commentary {
  margin-top: 0.55rem;
  border: 1px solid #c9b89a;
  border-radius: 10px;
  padding: 0.55rem;
  font-size: 0.86rem;
  background: #fffdf4;
  color: #3f3a2f;
}

.finalize-content {
  margin-top: 0.7rem;
  display: grid;
  gap: 0.8rem;
  max-height: 70vh;
  overflow: auto;
  padding-right: 0.2rem;
}

.finalize-content .recommend-item {
  white-space: pre-wrap;
  line-height: 1.35;
}

.insight-item, .recommend-item {
  border: 1px solid #d9c8ac;
  border-radius: 10px;
  background: #fff8eb;
  padding: 0.55rem;
  font-size: 0.88rem;
}

.insight-item.warning {
  border-color: #c05a5a;
  background: #fff3f3;
}

.insight-item.good {
  border-color: #77a17d;
  background: #f4fff4;
}

.recommend-item button {
  margin-top: 0.35rem;
  font-size: 0.8rem;
  padding: 0.35rem 0.6rem;
}

.plan-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 0.35rem;
}

.plan-diff {
  margin-top: 0.45rem;
  border: 1px dashed #c9b596;
  border-radius: 8px;
  padding: 0.4rem 0.5rem;
  font-size: 0.8rem;
  color: #5a4f3d;
}

.recommend-head {
  margin-top: 0.8rem;
}

.event-dialog {
  border: 0;
  padding: 0;
  border-radius: 14px;
  max-width: 680px;
  width: calc(100% - 2rem);
}

.event-dialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
}

.dialog-body {
  padding: 1rem;
  background: #fffcf4;
}

.dialog-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.7rem;
}

.questionnaire-form {
  display: grid;
  gap: 0.55rem;
}

.import-section {
  margin-bottom: 1.2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
}

.import-section:last-of-type {
  border-bottom: none;
}

.import-section h4 {
  margin: 0 0 0.4rem;
  font-size: 0.95rem;
  color: var(--ink);
}

.import-section p {
  margin: 0 0 0.6rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.import-section textarea {
  width: 100%;
  font-family: monospace;
  font-size: 0.85rem;
  margin-bottom: 0.6rem;
}

.import-divider {
  text-align: center;
  color: var(--muted);
  margin: 1rem 0;
  font-size: 0.85rem;
  font-weight: 600;
}

.import-steps {
  margin: 0.5rem 0;
  padding-left: 1.4rem;
  font-size: 0.9rem;
  color: var(--ink);
}

.import-steps li {
  margin-bottom: 0.35rem;
  line-height: 1.4;
}

.import-note {
  background: color-mix(in oklab, var(--bg-1) 70%, transparent);
  padding: 0.7rem;
  border-radius: 8px;
  border-left: 3px solid var(--accent);
  border-bottom: none;
  margin-bottom: 0;
}

.import-note p {
  margin: 0.3rem 0;
  font-size: 0.85rem;
}

.hidden {
  display: none !important;
}

.guide-dialog {
  max-width: 700px;
}

.guide-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.2rem;
}

.guide-header h2 {
  margin: 0;
  font-size: 1.4rem;
}

.close-x {
  background: transparent;
  color: var(--muted);
  font-size: 1.5rem;
  padding: 0;
  width: 32px;
  height: 32px;
  border: none;
  cursor: pointer;
  transition: color 150ms ease;
}

.close-x:hover {
  color: var(--ink);
  transform: none;
  filter: none;
}

.guide-tabs {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid var(--line);
  padding-bottom: 0;
}

.guide-tab {
  background: transparent;
  color: var(--muted);
  padding: 0.7rem 1rem;
  border: none;
  border-bottom: 3px solid transparent;
  font-weight: 600;
  cursor: pointer;
  transition: color 150ms ease, border-color 150ms ease;
}

.guide-tab:hover {
  color: var(--ink);
  transform: none;
  filter: none;
}

.guide-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.guide-content {
  position: relative;
  min-height: 300px;
  margin-bottom: 1.5rem;
}

.guide-panel {
  display: none;
  animation: fadeIn 200ms ease;
}

.guide-panel.active {
  display: block;
}

.guide-panel h3 {
  margin: 0 0 0.8rem;
  font-size: 1.1rem;
  color: var(--ink);
}

.guide-panel > p {
  margin: 0 0 0.8rem;
  color: var(--ink);
  line-height: 1.5;
}

.guide-steps {
  margin: 0;
  padding-left: 1.5rem;
}

.guide-steps li {
  margin-bottom: 1rem;
  line-height: 1.6;
}

.guide-steps strong {
  color: var(--ink);
}

.guide-steps p {
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.guide-list {
  margin: 0.5rem 0;
  padding-left: 1.5rem;
  list-style: disc;
}

.guide-list li {
  margin-bottom: 0.5rem;
  line-height: 1.5;
  color: var(--ink);
}

.guide-list strong {
  color: var(--ink);
}

.guide-list ul {
  margin: 0.3rem 0 0;
  padding-left: 1.2rem;
  list-style: circle;
  font-size: 0.95rem;
}

kbd {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.2rem 0.4rem;
  font-family: monospace;
  font-size: 0.85rem;
  color: var(--ink);
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes settle {
  0% { transform: translateY(10px) scale(0.98); opacity: 0; }
  60% { transform: translateY(-4px) scale(1.01); opacity: 1; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

@keyframes bouncePulse {
  0% { transform: scale(0.94); }
  45% { transform: scale(1.06); }
  75% { transform: scale(0.98); }
  100% { transform: scale(1); }
}

.bounce {
  animation: bouncePulse 480ms cubic-bezier(0.22, 1.45, 0.34, 1);
}

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

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

  .results-list {
    max-height: 55vh;
  }

  .event-block {
    left: 64px;
  }
}
