/* === Reset & Base === */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #0f0f14;
  --bg-card: #1a1a24;
  --bg-card-hover: #22222f;
  --bg-elevated: #252533;
  --text: #e8e8f0;
  --text-muted: #8888a0;
  --text-dim: #5a5a72;
  --accent: #e8435a;
  --accent-soft: rgba(232, 67, 90, 0.15);
  --tokyo: #a855f7;
  --tokyo-soft: rgba(168, 85, 247, 0.12);
  --kyoto: #f59e0b;
  --kyoto-soft: rgba(245, 158, 11, 0.12);
  --disney: #14b8a6;
  --disney-soft: rgba(20, 184, 166, 0.12);
  --travel: #10b981;
  --travel-soft: rgba(16, 185, 129, 0.12);
  --nara: #ec4899;
  --nara-soft: rgba(236, 72, 153, 0.12);
  --time-morning: #f59e0b;
  --time-afternoon: #38bdf8;
  --time-evening: #a855f7;
  --time-food: var(--accent);
  --time-all-day: var(--text-muted);
  --radius: 12px;
  --radius-sm: 8px;
  --font: 'Inter', 'Noto Sans JP', -apple-system, sans-serif;
  --header-height: 96px;
  --footer-height: 64px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}

/* === Date Bar === */
#date-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: linear-gradient(180deg, var(--bg) 0%, rgba(15, 15, 20, 0.95) 100%);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: calc(var(--safe-top) + 8px) 16px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.date-bar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.nav-btn {
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.nav-btn:active {
  background: var(--bg-elevated);
  transform: scale(0.92);
}

#date-display {
  text-align: center;
  flex: 1;
  min-width: 0;
}

#date-label {
  display: block;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

#day-subtitle {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
  font-weight: 400;
}

#date-pills {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 8px 0 2px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

#date-pills::-webkit-scrollbar {
  display: none;
}

.date-pill {
  flex-shrink: 0;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.date-pill:active {
  transform: scale(0.95);
}

.date-pill.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

/* === Main Content === */
#activities {
  position: fixed;
  top: var(--header-height);
  bottom: var(--footer-height);
  left: 0;
  right: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 16px calc(var(--safe-bottom) + 16px);
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

#activities-content {
  max-width: 600px;
  margin: 0 auto;
}

/* Day tag */
.day-tag {
  display: inline-block;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 14px;
}

.day-tag.tokyo {
  background: var(--tokyo-soft);
  color: var(--tokyo);
}

.day-tag.kyoto {
  background: var(--kyoto-soft);
  color: var(--kyoto);
}

.day-tag.disney {
  background: var(--disney-soft);
  color: var(--disney);
}

.day-tag.travel {
  background: var(--travel-soft);
  color: var(--travel);
}

.day-tag.nara {
  background: var(--nara-soft);
  color: var(--nara);
}

/* Time block */
.time-block {
  margin-bottom: 20px;
}

.time-label {
  font-size: 15px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin-bottom: 10px;
  padding-left: 2px;
}

.time-label.morning   { color: var(--time-morning); }
.time-label.afternoon { color: var(--time-afternoon); }
.time-label.evening   { color: var(--time-evening); }
.time-label.all_day   { color: var(--time-all-day); }
.time-label.food      { color: var(--time-food); }

/* Activity card */
.activity-card {
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 8px;
  transition: all 0.2s;
}

.activity-card:active {
  background: var(--bg-card-hover);
}

.activity-name {
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1.3;
}

.activity-emoji {
  font-size: 18px;
  flex-shrink: 0;
}

.activity-desc {
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 6px;
  line-height: 1.5;
}

.activity-address {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 8px;
  padding: 4px 8px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  font-family: 'Noto Sans JP', sans-serif;
  word-break: keep-all;
}

.activity-address:active {
  background: rgba(255, 255, 255, 0.08);
}

.activity-address .copy-icon {
  font-size: 11px;
  opacity: 0.5;
}

.activity-time {
  font-size: 12px;
  color: var(--accent);
  font-weight: 500;
  margin-top: 4px;
}

/* Time-period left borders */
.time-block.morning .activity-card   { border-left: 3px solid var(--time-morning); }
.time-block.afternoon .activity-card { border-left: 3px solid var(--time-afternoon); }
.time-block.evening .activity-card   { border-left: 3px solid var(--time-evening); }
.time-block.all_day .activity-card   { border-left: 3px solid var(--text-dim); }
.time-block.food .activity-card      { border-left: 3px solid var(--time-food); }

/* Food card variant — gray border override */
.activity-card.food {
  border-left: 3px solid #6b7280 !important;
  background: linear-gradient(135deg, var(--bg-card) 0%, rgba(107, 114, 128, 0.04) 100%);
}

.activity-card.food .activity-name {
  font-style: italic;
  font-weight: 500;
  color: var(--text-muted);
  font-size: 14px;
}

/* Simple text items */
.activity-simple {
  font-size: 14px;
  color: var(--text-muted);
  padding: 6px 0 6px 28px;
  line-height: 1.5;
}

/* Options block */
.options-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.option-block {
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.option-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: 10px;
}

/* === Bottom Bar === */
#bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--footer-height);
  background: linear-gradient(0deg, var(--bg) 0%, rgba(15, 15, 20, 0.95) 100%);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding-bottom: var(--safe-bottom);
}

.bottom-action {
  background: none;
  border: none;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.bottom-action:active {
  transform: scale(0.92);
  color: var(--text);
}

.btn-icon {
  font-size: 20px;
}

.btn-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.03em;
}

/* === Modals === */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  transition: opacity 0.25s;
}

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

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
}

.modal-content {
  position: relative;
  background: var(--bg-card);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 600px;
  max-height: 50vh;
  overflow-y: auto;
  padding: 20px;
  transform: translateY(0);
  transition: transform 0.3s;
}

.modal.hidden .modal-content {
  transform: translateY(100%);
}

.modal-content.modal-tall {
  max-height: 70vh;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-shrink: 0;
}

.modal-header h2 {
  font-size: 18px;
  font-weight: 600;
}

.modal-close {
  background: var(--bg-elevated);
  border: none;
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* === Weather === */
.weather-card {
  background: var(--bg-elevated);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 8px;
}

.weather-day {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
}

.weather-temp {
  font-size: 24px;
  font-weight: 700;
}

.weather-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

.weather-details {
  display: flex;
  gap: 16px;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-dim);
}

.weather-loading,
.weather-error {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-muted);
  font-size: 14px;
}

/* === Chat === */
#chat-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 12px;
}

.chat-welcome {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-muted);
}

.chat-welcome p {
  font-size: 14px;
  margin-bottom: 8px;
}

.chat-hint {
  font-size: 12px;
  color: var(--text-dim);
}

.chat-msg {
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 8px;
  font-size: 14px;
  line-height: 1.5;
  max-width: 85%;
}

.chat-msg.user {
  background: var(--accent);
  color: white;
  margin-left: auto;
  border-bottom-right-radius: 4px;
}

.chat-msg.assistant {
  background: var(--bg-elevated);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

#chat-input-area {
  display: flex;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

#chat-input {
  flex: 1;
  background: var(--bg-elevated);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 24px;
  font-size: 14px;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.2s;
}

#chat-input:focus {
  border-color: var(--accent);
}

#chat-input::placeholder {
  color: var(--text-dim);
}

#chat-send {
  background: var(--accent);
  border: none;
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s;
}

#chat-send:active {
  transform: scale(0.9);
}

/* === Settings === */
.setting-group {
  margin-bottom: 16px;
}

.setting-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.setting-toggle {
  display: flex;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.toggle-option {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.2s;
}

.toggle-option.active {
  background: var(--accent);
  color: white;
}

#api-key-input {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.2s;
}

#api-key-input:focus {
  border-color: var(--accent);
}

#api-key-input::placeholder {
  color: var(--text-dim);
}

.btn-primary {
  width: 100%;
  background: var(--accent);
  border: none;
  color: white;
  padding: 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary:active {
  transform: scale(0.98);
  opacity: 0.9;
}

#settings-status {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 8px;
}

/* === Toast === */
.toast {
  position: fixed;
  bottom: calc(var(--footer-height) + 16px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elevated);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 13px;
  font-weight: 500;
  z-index: 300;
  transition: all 0.3s;
  white-space: nowrap;
}

.toast.hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(10px);
  pointer-events: none;
}

/* === Scrollbar === */
::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

/* === Day Title in Content === */
.day-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
  letter-spacing: -0.02em;
}

.day-theme {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
  font-weight: 400;
}

/* === Lucide Icon Sizes === */
.lucide-icon {
  width: 20px;
  height: 20px;
  stroke-width: 2;
}

.lucide-header {
  width: 20px;
  height: 20px;
  stroke-width: 2;
  vertical-align: -3px;
  margin-right: 4px;
}

.lucide-sm {
  width: 16px;
  height: 16px;
  stroke-width: 2;
  vertical-align: -2px;
}

.lucide-xs {
  width: 13px;
  height: 13px;
  stroke-width: 2;
  opacity: 0.5;
  vertical-align: -1px;
}

/* === Activity Header (name + complete button row) === */
.activity-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.activity-header .activity-name {
  flex: 1;
  min-width: 0;
}

/* === Complete Button === */
.complete-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  padding: 2px;
  cursor: pointer;
  flex-shrink: 0;
  border-radius: 50%;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.complete-btn:hover {
  color: var(--text-muted);
}

.complete-btn.active {
  color: #10b981;
}

/* === Completed State === */
.activity-card.completed {
  opacity: 0.55;
}

.activity-card.completed .activity-name span {
  text-decoration: line-through;
  text-decoration-color: var(--text-dim);
}

.activity-card.completed .activity-desc,
.activity-card.completed .activity-time {
  opacity: 0.6;
}

/* === Optional Badge === */
.optional-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 10px;
  background: rgba(245, 158, 11, 0.12);
  color: #f59e0b;
  flex-shrink: 0;
  line-height: 1.4;
}

.activity-card.optional {
  border-style: dashed;
  border-right-style: dashed;
  border-top-style: dashed;
  border-bottom-style: dashed;
}

/* === Add Activity Button === */
.add-activity-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 10px;
  margin-top: 4px;
  margin-bottom: 8px;
  background: none;
  border: 2px dashed rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.2s;
}

.add-activity-btn:hover {
  border-color: rgba(255, 255, 255, 0.15);
  color: var(--text-muted);
}

.add-activity-btn:active {
  transform: scale(0.98);
}

/* === Edit Modal Form === */
#edit-form input[type="text"],
#edit-form input[type="number"],
#edit-form input[type="password"],
#edit-form textarea,
#edit-form select {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.2s;
}

#edit-form input:focus,
#edit-form textarea:focus,
#edit-form select:focus {
  border-color: var(--accent);
}

#edit-form input::placeholder,
#edit-form textarea::placeholder {
  color: var(--text-dim);
}

#edit-form select {
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238888a0' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

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

.edit-emoji-group {
  flex: 0 0 72px;
}

.edit-emoji-group input {
  text-align: center;
  font-size: 20px;
}

.edit-name-group {
  flex: 1;
}

.edit-checks {
  display: flex;
  gap: 16px;
  padding: 4px 0 8px;
}

.check-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
}

.check-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

.edit-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.edit-actions .btn-primary {
  flex: 1;
  width: auto;
}

/* === Button Variants === */
.btn-secondary {
  background: var(--bg-elevated);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
}

.btn-secondary:active {
  transform: scale(0.97);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #ef4444;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-danger:active {
  transform: scale(0.97);
  opacity: 0.8;
}

/* === PIN Modal === */
.pin-body {
  padding: 8px 0;
}

.pin-body input {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-family: var(--font);
  text-align: center;
  letter-spacing: 0.15em;
  outline: none;
  transition: border-color 0.2s;
}

.pin-body input:focus {
  border-color: var(--accent);
}

.pin-body input::placeholder {
  color: var(--text-dim);
  letter-spacing: 0;
}

/* === Lock Button States === */
#lock-btn {
  transition: all 0.2s;
}

#lock-btn.unlocked {
  color: #10b981;
}

/* === Export Grid === */
.export-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* === Settings / Edit Body Scroll === */
#settings-body,
#edit-body {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

/* === Settings Divider === */
.setting-divider {
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  margin: 20px 0;
}
