/* ===== ベース ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #faf7f2;
  --bg-deco: #f3ede3;
  --card: #ffffff;
  --ink: #33303b;
  --sub: #8f8c99;
  --faint: #b9b6c2;
  --line: #ece8df;
  --accent: #ff7a59;
  --accent-deep: #f2603c;
  --accent-soft: #ffece5;
  --blue: #4a7dff;
  --blue-soft: #ecf1ff;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(45, 38, 28, 0.04), 0 6px 20px -6px rgba(45, 38, 28, 0.10);
  --shadow-lift: 0 2px 4px rgba(45, 38, 28, 0.06), 0 14px 32px -8px rgba(45, 38, 28, 0.16);

  /* カテゴリ色（タイムライン） */
  --cat-move: #4a7dff;
  --cat-food: #f0930a;
  --cat-sight: #2fa356;
  --cat-stay: #8b5cf6;
  --cat-shop: #e5588f;
  --cat-nature: #159f8c;
  --cat-other: #9a96a5;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17151c;
    --bg-deco: #201d27;
    --card: #23202b;
    --ink: #eceaf1;
    --sub: #9d99a8;
    --faint: #6b6876;
    --line: #35323e;
    --accent: #ff8563;
    --accent-deep: #ff6f47;
    --accent-soft: #3a2a25;
    --blue: #8fb0ff;
    --blue-soft: #272c3f;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.25), 0 6px 20px -6px rgba(0, 0, 0, 0.45);
    --shadow-lift: 0 2px 4px rgba(0, 0, 0, 0.3), 0 14px 32px -8px rgba(0, 0, 0, 0.55);

    --cat-move: #8fb0ff;
    --cat-food: #ffb95c;
    --cat-sight: #6cd490;
    --cat-stay: #b79bfb;
    --cat-shop: #f48ab4;
    --cat-nature: #5cd0be;
    --cat-other: #8d8998;
  }
}

html { scroll-behavior: smooth; }

body {
  font-family: "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", sans-serif;
  font-weight: 500;
  background:
    radial-gradient(1000px 500px at 85% -10%, var(--bg-deco), transparent 60%),
    var(--bg);
  color: var(--ink);
  line-height: 1.65;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

#app { max-width: 620px; margin: 0 auto; padding: 20px 18px 96px; }

button { font-family: inherit; cursor: pointer; color: inherit; }
input, textarea { font-family: inherit; color: var(--ink); }

.hidden { display: none !important; }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes pop {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ===== 引っ越し案内バナー ===== */
.move-banner {
  background: var(--blue-soft); border: 1.5px solid var(--blue);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 16px;
  font-size: 13px; line-height: 1.7;
  animation: rise 0.4s ease both;
}
.move-banner b { display: block; }
.move-banner a { color: var(--blue); font-weight: 800; word-break: break-all; }
.move-banner small { display: block; color: var(--sub); margin-top: 4px; }

/* ===== ヒーロー（ホーム） ===== */
.hero {
  position: relative;
  background: linear-gradient(135deg, #ff8a5c 0%, #ff6a45 55%, #f2497c 130%);
  border-radius: 24px;
  padding: 34px 26px 28px;
  margin-bottom: 28px;
  color: #fff;
  overflow: hidden;
  box-shadow: 0 16px 40px -12px rgba(242, 96, 60, 0.45);
  animation: pop 0.45s cubic-bezier(0.2, 0.8, 0.3, 1) both;
}
.hero::before, .hero::after {
  content: ""; position: absolute; border-radius: 50%;
  background: rgba(255, 255, 255, 0.10); pointer-events: none;
}
.hero::before { width: 220px; height: 220px; top: -110px; right: -60px; }
.hero::after  { width: 140px; height: 140px; bottom: -70px; left: -40px; }

.hero-art {
  position: absolute; top: 18px; right: 22px; font-size: 34px;
  transform: rotate(-12deg); opacity: 0.9;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.15));
}

.app-title {
  font-size: 34px; font-weight: 900; letter-spacing: 0.03em; line-height: 1.2;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}
.app-title .logo {
  background: rgba(255, 255, 255, 0.22);
  border-radius: 12px; padding: 0 10px; margin-right: 4px;
}
.app-tagline { font-size: 14px; opacity: 0.94; margin: 8px 0 22px; font-weight: 700; }

.hero-cta {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  background: #fff; color: var(--accent-deep);
  border: none; border-radius: 999px;
  padding: 15px 20px; font-size: 15.5px; font-weight: 800;
  box-shadow: 0 8px 20px -6px rgba(60, 20, 5, 0.35);
  transition: transform 0.15s, box-shadow 0.15s;
}
.hero-cta span { font-size: 18px; }
.hero-cta:hover { transform: translateY(-2px); box-shadow: 0 12px 26px -6px rgba(60, 20, 5, 0.4); }
.hero-cta:active { transform: translateY(0) scale(0.98); }

.hero-sub {
  display: block; width: 100%; margin-top: 12px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px; color: #fff;
  padding: 10px 16px; font-size: 13px; font-weight: 700;
  transition: background 0.15s;
}
.hero-sub small { display: block; font-size: 10.5px; font-weight: 500; opacity: 0.85; }
.hero-sub:hover { background: rgba(255, 255, 255, 0.24); }

/* ===== ホーム：旅行カード ===== */
.section-label {
  font-size: 12.5px; font-weight: 800; color: var(--sub);
  letter-spacing: 0.08em; margin: 0 0 12px 6px;
}

.trip-card {
  background: var(--card); border-radius: var(--radius); padding: 16px;
  margin-bottom: 12px; box-shadow: var(--shadow); cursor: pointer;
  display: flex; align-items: center; gap: 14px;
  border: 1px solid var(--line);
  transition: transform 0.15s, box-shadow 0.15s;
  animation: rise 0.4s cubic-bezier(0.2, 0.8, 0.3, 1) both;
}
.trip-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.trip-card:active { transform: scale(0.99); }

.trip-emoji {
  width: 48px; height: 48px; border-radius: 14px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 24px;
}
.trip-emoji.av-0 { background: linear-gradient(135deg, #ffe3d6, #ffd0bd); }
.trip-emoji.av-1 { background: linear-gradient(135deg, #dbe7ff, #c9dbff); }
.trip-emoji.av-2 { background: linear-gradient(135deg, #ddf3e3, #c8ecd4); }
.trip-emoji.av-3 { background: linear-gradient(135deg, #f0e4ff, #e4d3ff); }
@media (prefers-color-scheme: dark) {
  .trip-emoji.av-0 { background: linear-gradient(135deg, #45301f, #4f3524); }
  .trip-emoji.av-1 { background: linear-gradient(135deg, #263050, #2b3760); }
  .trip-emoji.av-2 { background: linear-gradient(135deg, #1f3d2b, #234832); }
  .trip-emoji.av-3 { background: linear-gradient(135deg, #362b4e, #3e3059); }
}

.trip-card .trip-info { flex: 1; min-width: 0; }
.trip-card .trip-name { font-weight: 800; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trip-card .trip-meta { font-size: 12px; color: var(--sub); }
.trip-card .chev { color: var(--faint); font-size: 22px; font-weight: 300; }

.empty-note {
  text-align: center; color: var(--sub); font-size: 14px; padding: 36px 0;
  animation: rise 0.4s ease both;
}
.empty-icon { font-size: 44px; margin-bottom: 10px; opacity: 0.8; }

/* ===== ボタン共通 ===== */
.btn {
  border: none; border-radius: 999px; padding: 11px 20px;
  font-size: 14.5px; font-weight: 800;
  transition: transform 0.12s, opacity 0.12s, box-shadow 0.12s;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: #fff; box-shadow: 0 6px 16px -4px rgba(242, 96, 60, 0.5);
}
.btn-primary:disabled { background: var(--line); color: var(--faint); box-shadow: none; cursor: default; }
.btn-secondary { background: var(--bg-deco); color: var(--ink); }
.btn-small { padding: 8px 15px; font-size: 13px; }

.btn-ghost {
  display: block; width: 100%; margin-top: 4px;
  background: none; border: 1.5px dashed var(--faint); color: var(--sub);
  border-radius: var(--radius); padding: 13px; font-size: 14px; font-weight: 700;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

.icon-btn {
  background: none; border: none; font-size: 15px; color: var(--sub);
  padding: 6px 9px; border-radius: 10px;
  transition: background 0.12s, color 0.12s;
}
.icon-btn:hover { background: var(--bg-deco); }
.icon-btn.danger:hover { color: #e0442e; background: var(--accent-soft); }
.icon-btn:disabled { opacity: 0.3; cursor: default; }

/* ===== 旅行画面 ===== */
.trip-topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-bottom: 14px; flex-wrap: wrap;
  animation: rise 0.35s ease both;
}
.back-btn {
  background: var(--card); border: 1px solid var(--line); border-radius: 999px;
  font-size: 13.5px; color: var(--sub); font-weight: 800;
  padding: 8px 16px; box-shadow: var(--shadow);
  transition: color 0.12s, transform 0.12s;
}
.back-btn:hover { color: var(--ink); transform: translateY(-1px); }

.trip-toolbar { display: flex; gap: 6px; }
.tool-btn {
  display: flex; align-items: center; gap: 5px;
  background: var(--card); border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 13px; font-size: 12.5px; font-weight: 700; color: var(--ink);
  box-shadow: var(--shadow);
  transition: transform 0.12s, box-shadow 0.12s;
}
.tool-btn span { font-size: 14px; }
.tool-btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-lift); }
.tool-btn:active { transform: scale(0.97); }

.trip-header { margin-bottom: 12px; animation: rise 0.35s 0.05s ease both; }
.trip-header h1 { line-height: 1.3; }
.trip-header h1 input {
  font-size: 23px; font-weight: 900; border: none; background: none;
  width: 100%; color: var(--ink); padding: 2px 4px; border-radius: 8px;
  letter-spacing: 0.01em;
}
.trip-header h1 input:focus { outline: 2px solid var(--blue); background: var(--card); }

/* 日タブ */
.day-tabs {
  display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 16px;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
  animation: rise 0.35s 0.1s ease both;
}
.day-tabs::-webkit-scrollbar { display: none; }
.day-tab {
  flex-shrink: 0; border: 1px solid var(--line); background: var(--card); color: var(--sub);
  border-radius: 999px; padding: 8px 17px; font-size: 13.5px; font-weight: 800;
  box-shadow: var(--shadow);
  transition: transform 0.12s, background 0.15s, color 0.15s;
}
.day-tab:hover { transform: translateY(-1px); }
.day-tab.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  border-color: transparent; color: #fff;
  box-shadow: 0 6px 16px -4px rgba(242, 96, 60, 0.5);
}
.day-tab.add { background: none; box-shadow: none; border-style: dashed; border-color: var(--faint); }
.day-tab.add:hover { color: var(--accent); border-color: var(--accent); }

.day-heading {
  display: flex; align-items: center; justify-content: space-between;
  margin: 2px 4px 14px; animation: rise 0.35s 0.12s ease both;
}
.day-heading input {
  border: none; background: none; font-size: 15px; font-weight: 800;
  color: var(--ink); flex: 1; padding: 3px 6px; border-radius: 8px;
}
.day-heading input:focus { outline: 2px solid var(--blue); background: var(--card); }
.day-heading .day-actions { display: flex; gap: 2px; }

/* ===== タイムライン ===== */
.timeline { position: relative; padding-left: 0; }
.timeline::before {
  content: ""; position: absolute; left: 21px; top: 12px; bottom: 12px;
  width: 3px; border-radius: 3px;
  background: linear-gradient(to bottom, var(--accent) 0%, var(--line) 40%);
}

.item-card {
  position: relative; margin: 0 0 12px 44px;
  background: var(--card); border-radius: var(--radius);
  border: 1px solid var(--line);
  padding: 13px 15px; box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  animation: rise 0.4s cubic-bezier(0.2, 0.8, 0.3, 1) both;
}
.item-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.item-card:active { transform: scale(0.99); }

/* タイムライン上のアイコン玉 */
.item-bubble {
  position: absolute; left: -44px; top: 10px;
  width: 37px; height: 37px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; background: var(--card);
  border: 2.5px solid var(--cat-other);
  box-shadow: 0 0 0 4px var(--bg);
  z-index: 1;
}
.cat-move   .item-bubble { border-color: var(--cat-move); }
.cat-food   .item-bubble { border-color: var(--cat-food); }
.cat-sight  .item-bubble { border-color: var(--cat-sight); }
.cat-stay   .item-bubble { border-color: var(--cat-stay); }
.cat-shop   .item-bubble { border-color: var(--cat-shop); }
.cat-nature .item-bubble { border-color: var(--cat-nature); }

/* カテゴリ色の縁取り */
.item-card::before {
  content: ""; position: absolute; left: 0; top: 12px; bottom: 12px;
  width: 4px; border-radius: 0 4px 4px 0; background: var(--cat-other); opacity: 0.85;
}
.cat-move::before   { background: var(--cat-move); }
.cat-food::before   { background: var(--cat-food); }
.cat-sight::before  { background: var(--cat-sight); }
.cat-stay::before   { background: var(--cat-stay); }
.cat-shop::before   { background: var(--cat-shop); }
.cat-nature::before { background: var(--cat-nature); }

.item-top { display: flex; align-items: center; gap: 8px; margin-bottom: 2px; }
.item-top:empty { display: none; }
.item-time {
  font-size: 12.5px; font-weight: 800; letter-spacing: 0.02em;
  color: var(--accent-deep); background: var(--accent-soft);
  border-radius: 7px; padding: 1px 9px; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
@media (prefers-color-scheme: dark) { .item-time { color: var(--accent); } }
.item-dur { font-size: 11px; color: var(--faint); font-weight: 700; }

.item-title { font-weight: 800; font-size: 15px; word-break: break-word; line-height: 1.5; }
.item-note {
  font-size: 12.5px; color: var(--sub); margin-top: 5px;
  padding-top: 5px; border-top: 1px dashed var(--line);
  white-space: pre-wrap; word-break: break-word;
}

/* ===== 編集フォーム ===== */
.edit-form {
  background: var(--card); border-radius: var(--radius); padding: 15px;
  margin: 0 0 12px 44px;
  border: 1px solid var(--blue);
  box-shadow: 0 0 0 3px var(--blue-soft), var(--shadow-lift);
  animation: pop 0.25s ease both;
}
.edit-row { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.edit-row .tilde { color: var(--faint); }
.time-input {
  border: 1.5px solid var(--line); border-radius: 10px; padding: 8px 9px;
  font-size: 14px; width: 112px; background: var(--bg); color: var(--ink);
  transition: border-color 0.12s;
}
.text-input, .note-input {
  width: 100%; border: 1.5px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font-size: 15px; background: var(--bg);
  transition: border-color 0.12s;
}
.text-input:focus, .note-input:focus, .time-input:focus { outline: none; border-color: var(--blue); background: var(--card); }
.note-input { resize: vertical; min-height: 58px; font-size: 13px; }
.edit-actions { display: flex; gap: 8px; align-items: center; margin-top: 12px; }
.edit-actions .spacer { flex: 1; }
.reorder-btns { display: flex; gap: 2px; }

/* ===== モーダル ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(25, 20, 16, 0.55);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; z-index: 100;
  padding: 16px; animation: fadeIn 0.2s ease both;
}
@keyframes fadeIn { from { opacity: 0; } }
.modal {
  background: var(--card); border-radius: 22px; padding: 22px;
  width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto;
  border: 1px solid var(--line);
  box-shadow: 0 24px 60px -12px rgba(0, 0, 0, 0.35);
  animation: pop 0.3s cubic-bezier(0.2, 0.8, 0.3, 1) both;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.modal-header h2 { font-size: 17px; font-weight: 900; }
.modal-hint { font-size: 12.5px; color: var(--sub); margin-bottom: 12px; }
.modal .text-input { margin-bottom: 10px; }

.prompt-copy-btn {
  display: block; width: 100%; margin: 0 0 12px; text-align: center;
  background: var(--blue-soft); color: var(--blue); border: none;
  line-height: 1.5; border-radius: 12px; white-space: normal;
  padding: 10px 14px; font-size: 12.5px; font-weight: 800;
  transition: transform 0.12s, opacity 0.12s;
}
.prompt-copy-btn:hover { transform: translateY(-1px); }
.prompt-copy-btn:active { transform: scale(0.98); }

.paste-area {
  width: 100%; min-height: 190px; border: 1.5px solid var(--line);
  border-radius: 14px; padding: 13px; font-size: 13px;
  resize: vertical; background: var(--bg); color: var(--ink);
  transition: border-color 0.15s;
}
.paste-area:focus { outline: none; border-color: var(--accent); background: var(--card); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }

.import-preview { margin-top: 12px; font-size: 13px; }
.import-preview .preview-ok {
  background: #e7f6ec; color: #1d7a40; border-radius: 12px;
  padding: 10px 14px; font-weight: 800;
}
.import-preview .preview-warn {
  background: #fff6e0; color: #a07400; border-radius: 12px; padding: 10px 14px;
}
@media (prefers-color-scheme: dark) {
  .import-preview .preview-ok { background: #1c3526; color: #6cd490; }
  .import-preview .preview-warn { background: #38301a; color: #e8c05a; }
}
.preview-days { margin-top: 8px; color: var(--sub); }
.preview-days li { margin-left: 22px; }

/* ===== 共同編集 ===== */
.collab-badge {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 6px; padding: 4px 12px;
  background: #e7f6ec; color: #1d7a40;
  border-radius: 999px; font-size: 11.5px; font-weight: 800;
}
@media (prefers-color-scheme: dark) {
  .collab-badge { background: #1c3526; color: #6cd490; }
}
.collab-dot {
  width: 7px; height: 7px; border-radius: 50%; background: #2fa356;
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}
.collab-mini { color: #1d7a40; font-weight: 700; }
@media (prefers-color-scheme: dark) { .collab-mini { color: #6cd490; } }

.share-option.collab { border-color: #9fd8b2; }
.share-option.collab:hover { border-color: #2fa356; }
@media (prefers-color-scheme: dark) { .share-option.collab { border-color: #2c5c3c; } }

/* ===== 共有モーダル ===== */
.share-option {
  display: flex; align-items: center; gap: 14px; width: 100%;
  background: var(--bg); border: 1.5px solid var(--line); border-radius: 14px;
  padding: 14px 16px; margin-bottom: 10px; text-align: left;
  transition: transform 0.12s, border-color 0.15s, box-shadow 0.15s;
}
.share-option:hover {
  transform: translateY(-1px); border-color: var(--accent);
  box-shadow: var(--shadow);
}
.share-option:active { transform: scale(0.99); }
.share-icon { font-size: 24px; flex-shrink: 0; }
.share-text b { display: block; font-size: 14.5px; font-weight: 800; }
.share-text small { display: block; font-size: 11.5px; color: var(--sub); line-height: 1.5; }

/* ===== 予定カードの外部リンク ===== */
.item-links {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  margin-top: 8px;
}
.item-links a {
  font-size: 11.5px; font-weight: 700; text-decoration: none;
  color: var(--sub); background: var(--bg); border: 1px solid var(--line);
  border-radius: 999px; padding: 3px 10px;
  transition: color 0.12s, border-color 0.12s, transform 0.12s;
}
.item-links a:hover { color: var(--accent-deep); border-color: var(--accent); transform: translateY(-1px); }
.pr-badge {
  font-size: 9.5px; font-weight: 800; color: var(--faint);
  border: 1px solid var(--line); border-radius: 4px; padding: 0 4px;
}

/* ===== フッター ===== */
.app-footer {
  text-align: center; margin-top: 28px; font-size: 11.5px; color: var(--faint);
  line-height: 1.8;
}
.app-footer a { color: var(--sub); }

/* ===== トースト ===== */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); border-radius: 999px;
  padding: 11px 24px; font-size: 13.5px; font-weight: 800; z-index: 200;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3); white-space: nowrap;
  animation: toastIn 0.3s cubic-bezier(0.2, 0.8, 0.3, 1) both;
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 16px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

@media (max-width: 420px) {
  #app { padding: 14px 14px 96px; }
  .hero { padding: 28px 20px 24px; }
  .app-title { font-size: 29px; }
  .time-input { width: 96px; }
  .tool-btn { padding: 7px 11px; font-size: 12px; }
}
