:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-soft: #fbfaf6;
  --text: #202124;
  --muted: #66706a;
  --line: #dedbd2;
  --brand: #147d78;
  --brand-deep: #0d4f51;
  --coral: #d9654f;
  --gold: #d59b2d;
  --sky: #5f8fc9;
  --shadow: 0 18px 42px rgba(42, 48, 45, 0.1);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Gowun Dodum", "Malgun Gothic", sans-serif;
  color: var(--text);
  background:
    linear-gradient(120deg, rgba(20, 125, 120, 0.08), transparent 34%),
    linear-gradient(240deg, rgba(217, 101, 79, 0.1), transparent 30%),
    var(--bg);
}

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

button {
  cursor: pointer;
}

.app-shell {
  width: min(1360px, 100%);
  margin: 0 auto;
  padding: 28px 22px 46px;
}

.session-bar,
.session-actions,
.page-header,
.panel-header,
.summary-strip,
.gallery-header,
.trip-topline,
.trip-actions,
.edit-actions {
  display: flex;
  align-items: center;
}

.session-bar {
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 28px;
}

.session-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.back-link,
.secondary-button,
.storage-mode,
.sync-status,
.user-pill {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
  color: var(--text);
  text-decoration: none;
}

.back-link,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 13px;
}

.storage-mode,
.sync-status,
.user-pill {
  display: inline-flex;
  align-items: center;
  padding: 9px 12px;
  color: var(--muted);
}

.storage-mode {
  color: var(--brand-deep);
  font-weight: 700;
}

.sync-status.is-error {
  color: #914338;
  border-color: rgba(217, 101, 79, 0.38);
  background: #fff5f1;
}

#logoutButton[hidden] {
  display: none;
}

.page-header {
  justify-content: space-between;
  align-items: end;
  gap: 22px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 8px;
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brand);
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2.2rem, 4.4vw, 4.4rem);
  line-height: 1;
}

.summary-strip {
  gap: 10px;
  flex-wrap: wrap;
}

.summary-strip div {
  min-width: 92px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 10px 26px rgba(42, 48, 45, 0.07);
}

.summary-strip span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.9rem;
}

.summary-strip strong {
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.5rem;
}

.layout {
  display: grid;
  grid-template-columns: minmax(300px, 390px) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.composer-panel,
.gallery-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
}

.composer-panel {
  position: sticky;
  top: 18px;
  padding: 22px;
}

.gallery-panel {
  padding: 22px;
}

.panel-header,
.gallery-header {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.panel-header h2,
.gallery-header h2 {
  margin-bottom: 0;
  font-size: 1.35rem;
}

.travel-form,
.edit-form {
  display: grid;
  gap: 14px;
}

.worldtravel-link-panel {
  display: grid;
  gap: 10px;
  border: 1px solid rgba(20, 125, 120, 0.34);
  border-left: 4px solid var(--brand);
  border-radius: 8px;
  padding: 12px;
  background: rgba(20, 125, 120, 0.07);
}

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

.worldtravel-link-panel > div:first-child {
  display: grid;
  gap: 4px;
}

.worldtravel-link-panel strong {
  color: var(--brand-deep);
  font-size: 0.92rem;
}

.worldtravel-link-panel span,
.linked-field-note {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

.worldtravel-link-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.worldtravel-link-actions a,
.worldtravel-link-actions button,
.linked-field-note a {
  border: 0;
  padding: 0;
  color: var(--brand-deep);
  background: transparent;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  text-decoration: none;
}

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

.evaluation-fields {
  display: grid;
  min-width: 0;
  margin: 0;
  padding: 14px 0 0;
  border: 0;
  border-top: 1px solid var(--line);
  gap: 12px;
}

.evaluation-fields legend {
  padding-right: 8px;
  color: var(--text);
  font-weight: 700;
}

.evaluation-fields legend small {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 400;
}

.field span,
.search-field span {
  color: var(--muted);
  font-size: 0.92rem;
}

.field small {
  font-size: 0.78rem;
  font-weight: 400;
}

.budget-input-wrap {
  display: flex;
  align-items: center;
  position: relative;
}

.budget-input-wrap input {
  padding-right: 42px;
}

.budget-input-wrap > span {
  position: absolute;
  right: 13px;
  color: var(--muted);
  font-size: 0.86rem;
  pointer-events: none;
}

.field input,
.field select,
.field textarea,
.search-field input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text);
  outline: none;
}

.field input,
.field select,
.search-field input {
  min-height: 44px;
  padding: 10px 12px;
}

.field textarea {
  min-height: 132px;
  padding: 12px;
  resize: vertical;
  line-height: 1.6;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.search-field input:focus {
  border-color: rgba(20, 125, 120, 0.7);
  box-shadow: 0 0 0 3px rgba(20, 125, 120, 0.14);
}

.field input[readonly] {
  cursor: default;
  border-color: rgba(20, 125, 120, 0.28);
  background: rgba(20, 125, 120, 0.06);
  color: var(--brand-deep);
}

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

.primary-button,
.edit-button,
.delete-button {
  border: 0;
  border-radius: 8px;
  transition: transform 0.16s ease, box-shadow 0.16s ease, opacity 0.16s ease;
}

.primary-button {
  min-height: 46px;
  padding: 11px 16px;
  background: var(--brand);
  color: #fff;
  box-shadow: 0 12px 22px rgba(20, 125, 120, 0.22);
}

.secondary-button:hover,
.secondary-button:focus-visible,
.primary-button:hover,
.primary-button:focus-visible,
.edit-button:hover,
.edit-button:focus-visible,
.delete-button:hover,
.delete-button:focus-visible,
.back-link:hover,
.back-link:focus-visible {
  transform: translateY(-1px);
}

.primary-button:disabled,
.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
  transform: none;
}

.gallery-header {
  align-items: end;
}

.gallery-header p {
  margin: 6px 0 0;
  color: var(--muted);
}

.search-field {
  width: min(280px, 100%);
}

.trip-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  align-items: start;
}

.trip-card,
.empty-state {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

.trip-card {
  min-width: 0;
  align-self: start;
  border-top: 4px solid var(--brand);
}

.trip-view {
  min-height: 0;
}

.trip-body {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  gap: 12px;
  min-height: 250px;
  padding: 16px;
}

.trip-topline {
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.date-pill,
.companion-pill,
.budget-pill {
  min-height: 28px;
  padding: 5px 8px;
  border-radius: 8px;
  font-size: 0.84rem;
}

.date-pill {
  background: rgba(20, 125, 120, 0.12);
  color: var(--brand-deep);
}

.companion-pill {
  margin-left: auto;
  background: rgba(217, 101, 79, 0.12);
  color: #8d3b2f;
}

.budget-pill {
  background: rgba(213, 155, 45, 0.14);
  color: #795714;
}

.linked-trip-badge {
  width: fit-content;
  color: #2f5d8f;
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: none;
}

.linked-trip-badge:hover,
.linked-trip-badge:focus-visible,
.linked-field-note a:hover,
.linked-field-note a:focus-visible,
.worldtravel-link-actions a:hover,
.worldtravel-link-actions a:focus-visible {
  text-decoration: underline;
}

.trip-location {
  margin-bottom: 0;
  font-size: 1.35rem;
  line-height: 1.25;
  word-break: keep-all;
}

.trip-itinerary {
  min-height: 4.8em;
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.6;
  white-space: pre-line;
  word-break: break-word;
}

.trip-evaluation {
  display: grid;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.trip-evaluation-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.rating-stars {
  color: #a66f08;
  font-size: 1rem;
  letter-spacing: 0;
}

.revisit-pill {
  min-height: 26px;
  padding: 4px 8px;
  border-radius: 8px;
  background: rgba(95, 143, 201, 0.14);
  color: #2f5d8f;
  font-size: 0.8rem;
}

.trip-review {
  margin: 0;
  color: var(--text);
  font-size: 0.92rem;
  line-height: 1.5;
  word-break: break-word;
}

.trip-actions {
  justify-content: flex-end;
  gap: 8px;
  margin-top: 2px;
}

.edit-button,
.delete-button {
  padding: 8px 11px;
}

.edit-button {
  background: rgba(95, 143, 201, 0.14);
  color: #2f5d8f;
}

.delete-button {
  background: rgba(217, 101, 79, 0.12);
  color: #8d3b2f;
}

.edit-form {
  padding: 16px;
  border-top: 1px solid var(--line);
  background: #fffdf8;
}

.linked-field-note {
  border-left: 3px solid var(--sky);
  padding: 8px 10px;
  background: rgba(95, 143, 201, 0.08);
}

.edit-actions {
  justify-content: flex-end;
  gap: 8px;
}

.empty-state {
  padding: 34px 20px;
  text-align: center;
  color: var(--muted);
}

@media (max-width: 980px) {
  .page-header,
  .layout {
    grid-template-columns: 1fr;
  }

  .page-header,
  .gallery-header {
    align-items: stretch;
    flex-direction: column;
  }

  .composer-panel {
    position: static;
  }

  .search-field {
    width: 100%;
  }
}

@media (max-width: 620px) {
  .app-shell {
    padding: 20px 14px 34px;
  }

  .session-actions,
  .session-actions > * {
    width: 100%;
  }

  .field-grid,
  .trip-list {
    grid-template-columns: 1fr;
  }
}
