:root {
  --bg: #f5f1e6;
  --bg-strong: #efe3cf;
  --ink: #1e2a2b;
  --muted: #5c6b6f;
  --panel: #ffffff;
  --panel-soft: #f7f2e8;
  --accent: #ff6b35;
  --accent-2: #1c7c7c;
  --accent-3: #f2c14e;
  --border: rgba(30, 42, 43, 0.12);
  --shadow: 0 24px 60px rgba(15, 20, 20, 0.16);
  --radius: 24px;
  --radius-lg: 32px;
  --font-sans: "Space Grotesk", sans-serif;
  --font-serif: "Fraunces", serif;
  color-scheme: light dark;
}

* {
  box-sizing: border-box;
}

html {
  background-color: var(--bg-strong);
}

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

body.app-body {
  margin: 0;
  min-height: 100vh;
  padding: calc(32px + env(safe-area-inset-top))
    calc(32px + env(safe-area-inset-right))
    calc(32px + env(safe-area-inset-bottom))
    calc(32px + env(safe-area-inset-left));
  font-family: var(--font-sans);
  line-height: 1.5;
  color: var(--ink);
  background-color: var(--bg-strong);
  background-image: radial-gradient(
      900px 600px at 5% -10%,
      rgba(255, 207, 170, 0.6),
      transparent 65%
    ),
    radial-gradient(
      800px 600px at 96% 6%,
      rgba(166, 227, 219, 0.55),
      transparent 60%
    ),
    linear-gradient(180deg, #fbf6ee 0%, var(--bg-strong) 100%);
  position: relative;
  overflow-x: hidden;
}

.bg-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(0px);
  opacity: 0.5;
  pointer-events: none;
  z-index: 0;
}

.orb-1 {
  width: 420px;
  height: 420px;
  top: -180px;
  left: -120px;
  background: radial-gradient(circle, rgba(255, 173, 103, 0.65), transparent);
}

.orb-2 {
  width: 520px;
  height: 520px;
  bottom: -240px;
  right: -140px;
  background: radial-gradient(circle, rgba(45, 156, 156, 0.4), transparent);
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image: linear-gradient(
      to right,
      rgba(30, 42, 43, 0.06) 1px,
      transparent 1px
    ),
    linear-gradient(
      to bottom,
      rgba(30, 42, 43, 0.06) 1px,
      transparent 1px
    );
  background-size: 64px 64px;
  opacity: 0.35;
  pointer-events: none;
  z-index: 0;
}

.app-shell {
  position: relative;
  z-index: 1;
  max-width: 1180px;
  margin: 0 auto;
  margin-top: 80px;
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(360px, 1.1fr);
  gap: 32px;
  align-items: start;
}

.app-shell.tutorial-dismissed {
  grid-template-columns: minmax(0, 860px);
  justify-content: center;
}

.app-shell.tutorial-dismissed .workspace {
  width: 100%;
}

.utility-buttons {
  position: fixed;
  top: 24px;
  right: 24px;
  display: inline-flex;
  gap: 10px;
  z-index: 5;
}

.icon-button {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 24px rgba(15, 20, 20, 0.12);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.icon-button:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 16px 28px rgba(15, 20, 20, 0.18);
}

.icon-button-small {
  position: static;
  width: 36px;
  height: 36px;
  box-shadow: none;
}

.hero {
  background: linear-gradient(140deg, rgba(255, 255, 255, 0.92), rgba(255, 244, 231, 0.9));
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 32px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.hero-dismiss {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(30, 42, 43, 0.2);
  background: rgba(255, 255, 255, 0.75);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.hero-dismiss:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 16px rgba(15, 20, 20, 0.15);
}

.hero::after {
  content: "";
  position: absolute;
  width: 140px;
  height: 140px;
  right: 20px;
  bottom: 20px;
  background: radial-gradient(circle, rgba(255, 107, 53, 0.22), transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(28, 124, 124, 0.12);
  color: var(--accent-2);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.7rem;
}

.badge-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.logo-mark {
  width: 72px;
  height: 72px;
  border-radius: 22px;
  background: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(30, 42, 43, 0.08);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.logo-icon {
  width: 48px;
  height: 48px;
}

.hero-title {
  font-family: var(--font-serif);
  font-size: clamp(2.2rem, 3vw, 3.4rem);
  line-height: 1.1;
  margin: 0;
}

.hero-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  max-width: 440px;
}

.hero-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.info-card {
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(30, 42, 43, 0.08);
  box-shadow: 0 12px 30px rgba(15, 20, 20, 0.08);
}

.info-title {
  display: block;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-2);
  margin-bottom: 4px;
  font-weight: 600;
}

.info-card p {
  margin: 0;
  color: var(--ink);
  font-weight: 500;
}

.workspace {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.panel {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 28px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 20px;
}

.panel-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.panel-header h2 {
  margin: 0;
  font-size: 1.4rem;
  font-family: var(--font-serif);
}

.panel-header p {
  margin: 0;
  color: var(--muted);
}

.panel-editor {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(248, 239, 223, 0.95));
  position: relative;
}

.panel-editor::before {
  content: "";
  position: absolute;
  inset: 16px;
  border-radius: 18px;
  background-image: linear-gradient(
      90deg,
      rgba(30, 42, 43, 0.04) 1px,
      transparent 1px
    ),
    linear-gradient(180deg, rgba(30, 42, 43, 0.03) 1px, transparent 1px);
  background-size: 32px 32px;
  opacity: 0.6;
  pointer-events: none;
}

.panel-editor > * {
  position: relative;
  z-index: 1;
}

.panel-actions {
  background: linear-gradient(135deg, #1f2a2b, #1c7c7c);
  color: #f7f5f1;
}

.panel-actions .panel-header p {
  color: rgba(247, 245, 241, 0.75);
}

.panel-results {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(246, 244, 238, 0.95));
}

.field-label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: var(--ink);
}

.input-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(30, 42, 43, 0.12);
}

.toggle-btn {
  border: none;
  background: transparent;
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.toggle-btn.is-active {
  background: var(--accent-2);
  color: #ffffff;
  box-shadow: 0 8px 16px rgba(15, 20, 20, 0.2);
}

.input-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field {
  width: 100%;
  border-radius: 18px;
  border: 1px solid rgba(30, 42, 43, 0.18);
  padding: 14px 16px;
  font-size: 1rem;
  font-family: var(--font-sans);
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.field:focus {
  outline: none;
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(28, 124, 124, 0.2);
}

.field::placeholder {
  color: rgba(92, 107, 111, 0.65);
}

.field-textarea {
  min-height: 160px;
  resize: vertical;
}

.field-select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 22px) 50%, calc(100% - 14px) 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  cursor: pointer;
}

.field-disabled {
  background: rgba(237, 231, 220, 0.8);
  color: rgba(30, 42, 43, 0.55);
  cursor: not-allowed;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.field-hint {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.field-error {
  margin: 0;
  font-size: 0.85rem;
  color: #c0392b;
}

.field-error-state {
  border-color: rgba(192, 57, 43, 0.9);
  box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.2);
}

.divider {
  position: relative;
  text-align: center;
  margin: 22px 0;
}

.divider::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1px;
  background: rgba(30, 42, 43, 0.16);
}

.divider span {
  position: relative;
  z-index: 1;
  background: var(--panel-soft);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.drop-zone {
  border: 2px dashed rgba(30, 42, 43, 0.28);
  border-radius: 20px;
  padding: 24px;
  background: rgba(255, 255, 255, 0.75);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
  cursor: pointer;
}

.drop-zone:hover {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 4px rgba(28, 124, 124, 0.18);
  transform: translateY(-1px);
}

.drop-zone:active {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(255, 107, 53, 0.22);
  transform: translateY(0);
}

.drag-over {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(255, 107, 53, 0.2);
}

.upload-prompt {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  color: var(--muted);
}

.upload-icon {
  width: 52px;
  height: 52px;
  color: var(--accent-2);
}

.upload-text {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  font-weight: 600;
}

.upload-link {
  color: var(--accent);
}

.upload-hint {
  margin: 0;
  font-size: 0.8rem;
}

.image-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.image-thumb {
  max-height: 160px;
  max-width: 100%;
  border-radius: 16px;
  box-shadow: 0 14px 30px rgba(15, 20, 20, 0.2);
}

.image-name {
  margin: 0;
  font-weight: 600;
  color: var(--ink);
}

.link-button {
  background: none;
  border: none;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
}

.action-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: none;
  border-radius: 999px;
  padding: 14px 20px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn svg {
  width: 20px;
  height: 20px;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(15, 20, 20, 0.2);
}

.btn:focus-visible,
.icon-button:focus-visible,
.link-button:focus-visible {
  outline: 3px solid rgba(255, 107, 53, 0.35);
  outline-offset: 2px;
}

.btn-primary {
  background: linear-gradient(120deg, #ff6b35, #f2c14e);
  color: #ffffff;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  border: 1px solid rgba(30, 42, 43, 0.2);
}

.panel-actions .btn-secondary {
  background: rgba(255, 255, 255, 0.2);
  color: #f7f5f1;
  border: 1px solid rgba(247, 245, 241, 0.3);
}

.btn-download {
  width: 100%;
  justify-content: center;
  background: linear-gradient(120deg, #1c7c7c, #2ecc71);
  color: #ffffff;
}

.btn-disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.btn:disabled,
.btn.btn-disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn:disabled:hover,
.btn.btn-disabled:hover {
  transform: none;
  box-shadow: none;
}

.status {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.status p {
  margin: 0;
}

.status.loading {
  background: rgba(255, 255, 255, 0.15);
  color: #f7f5f1;
}

.status.error {
  background: rgba(255, 222, 217, 0.95);
  color: #8b2c1f;
  border: 1px solid rgba(139, 44, 31, 0.2);
}

.custom-loader {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: #ffffff;
  animation: spin 0.9s linear infinite;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.result-card {
  border-radius: 20px;
  padding: 20px;
  border: 1px solid rgba(30, 42, 43, 0.16);
  background: #ffffff;
  box-shadow: 0 12px 24px rgba(15, 20, 20, 0.1);
  position: relative;
  overflow: hidden;
  animation: fadeIn 0.5s ease-out forwards;
  opacity: 0;
}

.result-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 6px;
  height: 100%;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
}

.result-title {
  margin: 0 0 12px;
  font-size: 1.2rem;
  font-family: var(--font-serif);
}

.result-meta {
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: var(--muted);
  font-size: 0.95rem;
}

.result-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.result-label {
  font-weight: 600;
  color: var(--ink);
  min-width: 52px;
}

.result-value {
  color: var(--muted);
  word-break: break-word;
}

.result-timezone {
  color: var(--muted);
  font-size: 0.85rem;
  opacity: 0.8;
}

.result-icon {
  width: 18px;
  height: 18px;
  margin-top: 2px;
}

.result-icon.start {
  color: var(--accent-2);
}

.result-icon.end {
  color: var(--accent);
}

.result-icon.location {
  color: var(--accent-3);
}

.result-desc {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(30, 42, 43, 0.12);
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
}

.download {
  margin-top: 20px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 20, 0.55);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow-y: auto;
  z-index: 10;
}

.modal-card {
  width: min(520px, 100%);
  background: var(--panel);
  border-radius: var(--radius);
  padding: 24px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.modal-card h2 {
  margin: 0;
  font-family: var(--font-serif);
}

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

.modal-subtitle {
  margin: 10px 0 18px;
  color: var(--muted);
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hidden {
  display: none !important;
}

.fade-in {
  animation: fadeIn 0.5s ease-out forwards;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes spin {
  to {
    transform: rotate(1turn);
  }
}

@media (max-width: 1180px) {
  body.app-body {
    --responsive-top-clearance: max(56px, calc(24px + env(safe-area-inset-top)));
    --utility-button-inset-right: max(32px, calc(24px + env(safe-area-inset-right)));
    padding: var(--responsive-top-clearance)
      calc(24px + env(safe-area-inset-right))
      calc(24px + env(safe-area-inset-bottom))
      calc(24px + env(safe-area-inset-left));
  }

  .app-shell {
    margin-top: 104px;
    min-width: 0;
    width: 100%;
  }

  .hero,
  .workspace,
  .panel {
    min-width: 0;
  }

  .utility-buttons {
    position: fixed;
    top: var(--responsive-top-clearance);
    right: var(--utility-button-inset-right);
  }

  .utility-buttons .icon-button {
    width: 48px;
    height: 48px;
  }
}

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

  .hero::after {
    right: -20px;
  }
}

@media (max-width: 640px) {
  body.app-body {
    --responsive-top-clearance: max(56px, calc(18px + env(safe-area-inset-top)));
    padding: var(--responsive-top-clearance)
      calc(18px + env(safe-area-inset-right))
      calc(18px + env(safe-area-inset-bottom))
      calc(18px + env(safe-area-inset-left));
  }

  .hero {
    padding: 24px;
  }

  .panel {
    padding: 20px;
  }

  .app-shell {
    margin-top: 104px;
  }

  .action-row {
    flex-direction: column;
  }

  .btn {
    width: 100%;
    justify-content: center;
  }

}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1412;
    --bg-strong: #0a0f0d;
    --ink: #f5f1e6;
    --muted: #aab2ad;
    --panel: #16201d;
    --panel-soft: #101715;
    --border: rgba(255, 255, 255, 0.08);
    --shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
    --accent: #ff8b5a;
    --accent-2: #4ecdc4;
    --accent-3: #f2c14e;
  }

  body.app-body {
    background-color: var(--bg-strong);
    background-image: radial-gradient(
        800px 600px at 12% -10%,
        rgba(255, 139, 90, 0.25),
        transparent 70%
      ),
      radial-gradient(
        700px 500px at 95% 10%,
        rgba(78, 205, 196, 0.2),
        transparent 60%
      ),
      linear-gradient(180deg, #0a0f0d 0%, #0e1412 100%);
  }

  .bg-grid {
    opacity: 0.2;
  }

  .icon-button {
    background: rgba(22, 32, 29, 0.9);
    color: var(--ink);
  }

  .hero {
    background: linear-gradient(140deg, rgba(22, 32, 29, 0.95), rgba(18, 25, 23, 0.9));
  }

  .hero-dismiss {
    background: rgba(22, 32, 29, 0.75);
    border-color: rgba(255, 255, 255, 0.2);
    color: var(--muted);
  }

  .info-card {
    background: rgba(22, 32, 29, 0.85);
  }

  .panel {
    background: var(--panel);
  }

  .panel-editor {
    background: linear-gradient(180deg, rgba(22, 32, 29, 0.98), rgba(19, 26, 24, 0.9));
  }

  .panel-actions {
    background: linear-gradient(135deg, #1a2c28, #0f4d4a);
  }

  .panel-results {
    background: linear-gradient(180deg, rgba(22, 32, 29, 0.95), rgba(18, 25, 23, 0.9));
  }

  .field {
    background: rgba(17, 24, 22, 0.9);
    border-color: rgba(255, 255, 255, 0.12);
    color: var(--ink);
  }

  .input-toggle {
    background: rgba(17, 24, 22, 0.7);
    border-color: rgba(255, 255, 255, 0.12);
  }

  .field::placeholder {
    color: rgba(170, 178, 173, 0.6);
  }

  .field-disabled {
    background: rgba(17, 24, 22, 0.6);
  }

  .divider span {
    background: var(--panel-soft);
  }

  .drop-zone {
    background: rgba(17, 24, 22, 0.8);
  }

  .btn-secondary {
    background: rgba(17, 24, 22, 0.7);
    color: var(--ink);
    border-color: rgba(255, 255, 255, 0.12);
  }

  .panel-actions .btn-secondary {
    background: rgba(255, 255, 255, 0.12);
    color: #f7f5f1;
    border: 1px solid rgba(255, 255, 255, 0.25);
  }

  .status.error {
    background: rgba(139, 44, 31, 0.2);
    color: #ffb8a8;
  }

  .result-card {
    background: rgba(17, 24, 22, 0.9);
  }

  .modal-card {
    background: var(--panel);
  }
}
