:root {
  --bg: #f6f3ee;
  --bg-elev: #ffffff;
  --ink: #1c1917;
  --ink-soft: #57534e;
  --line: #e7e0d6;
  --teal: #0f766e;
  --teal-deep: #115e59;
  --teal-soft: #ccfbf1;
  --coral: #e11d48;
  --sand: #faf6f0;
  --shadow: 0 10px 30px rgba(28, 25, 23, 0.08);
  --radius: 18px;
  --radius-sm: 12px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --font: "IBM Plex Sans JP", "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif;
  --max: 440px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: #ddd5c8;
  color: var(--ink);
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100dvh;
}

#app {
  max-width: var(--max);
  margin: 0 auto;
  min-height: 100dvh;
  background:
    radial-gradient(1200px 400px at 10% -10%, #99f6e4 0%, transparent 55%),
    radial-gradient(900px 300px at 100% 0%, #fecdd3 0%, transparent 50%),
    var(--bg);
  position: relative;
  overflow-x: hidden;
}

.view {
  display: none;
  min-height: 100dvh;
  padding: calc(16px + var(--safe-t)) 16px calc(28px + var(--safe-b));
}

.view.active {
  display: block;
}

#view-trip.active {
  padding-bottom: calc(88px + var(--safe-b));
}

/* Top */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--teal);
  font-weight: 600;
}

.brand {
  margin: 2px 0 0;
  font-size: 28px;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(145deg, var(--teal), #0d9488);
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.hero-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 16px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.hero-title {
  margin: 0 0 6px;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.4;
}

.hero-sub {
  margin: 0;
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.6;
}

.stack {
  display: grid;
  gap: 10px;
  margin-bottom: 28px;
}

.btn {
  appearance: none;
  border: none;
  border-radius: 14px;
  min-height: 52px;
  padding: 0 16px;
  font: inherit;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.12s ease, opacity 0.12s ease;
}

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

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

.btn-primary {
  background: linear-gradient(180deg, #0f766e 0%, #0d5f59 100%);
  color: #fff;
  box-shadow: 0 8px 20px rgba(15, 118, 110, 0.28);
}

.btn-secondary {
  background: var(--bg-elev);
  color: var(--teal-deep);
  border: 1px solid var(--line);
}

.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
}

.btn-danger {
  background: #fff1f2;
  color: var(--coral);
  border: 1px solid #fecdd3;
}

.btn-ico {
  font-size: 18px;
  line-height: 1;
}

.section-head h2 {
  margin: 0 0 12px;
  font-size: 15px;
  color: var(--ink-soft);
  font-weight: 600;
}

.trip-list {
  display: grid;
  gap: 10px;
}

.trip-card {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  border-radius: var(--radius);
  padding: 14px 14px 12px;
  box-shadow: 0 4px 14px rgba(28, 25, 23, 0.04);
  cursor: pointer;
  font: inherit;
  color: inherit;
}

.trip-card:active {
  transform: scale(0.99);
}

.trip-card h3 {
  margin: 0 0 4px;
  font-size: 16px;
}

.trip-card p {
  margin: 0;
  font-size: 12px;
  color: var(--ink-soft);
}

.trip-card .code-pill {
  display: inline-block;
  margin-top: 8px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--teal-soft);
  color: var(--teal-deep);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.empty-hint {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.6;
}

.empty-hint.hidden {
  display: none;
}

/* Trip view */
.trip-top {
  align-items: flex-start;
}

.trip-top-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: stretch;
}

.trip-top-actions .icon-btn {
  min-width: 48px;
}

.btn-block {
  width: 100%;
  margin-top: 12px;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.btn-mini.danger {
  border-color: #fecdd3;
  background: #fff1f2;
  color: var(--coral);
}

.trip-card-wrap {
  position: relative;
}

.trip-card-wrap .trip-card {
  padding-right: 72px;
}

.trip-card-actions {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.trip-card-actions button {
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  color: var(--teal-deep);
  cursor: pointer;
}

.trip-card-actions button.danger {
  border-color: #fecdd3;
  color: var(--coral);
  background: #fff1f2;
}

.trip-head-text {
  flex: 1;
  min-width: 0;
  text-align: center;
}

.trip-head-text h1 {
  margin: 0;
  font-size: 18px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meta-line {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--ink-soft);
}

.icon-btn {
  min-width: 48px;
  min-height: 40px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  border-radius: 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  padding: 0 10px;
}

.day-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 2px 12px;
  margin: 0 -4px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.day-scroll::-webkit-scrollbar {
  display: none;
}

.day-tab {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  border-radius: 14px;
  padding: 10px 12px;
  min-width: 72px;
  text-align: center;
  font: inherit;
  cursor: pointer;
  color: var(--ink);
}

.day-tab .d-label {
  display: block;
  font-size: 11px;
  color: var(--ink-soft);
  font-weight: 600;
}

.day-tab .d-date {
  display: block;
  margin-top: 2px;
  font-size: 14px;
  font-weight: 700;
}

.day-tab.active {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}

.day-tab.active .d-label {
  color: rgba(255, 255, 255, 0.8);
}

.budget-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--sand);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 14px;
}

.budget-bar strong {
  font-size: 16px;
  color: var(--teal-deep);
}

.item-list {
  display: grid;
  gap: 10px;
}

.item-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 12px 12px 14px;
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 10px;
  box-shadow: 0 4px 12px rgba(28, 25, 23, 0.04);
  cursor: pointer;
  text-align: left;
  width: 100%;
  font: inherit;
  color: inherit;
}

.item-card:active {
  transform: scale(0.99);
}

.item-time {
  font-size: 13px;
  font-weight: 700;
  color: var(--teal);
  padding-top: 2px;
}

.item-body h3 {
  margin: 0 0 4px;
  font-size: 15px;
  line-height: 1.35;
}

.item-meta {
  margin: 0;
  font-size: 12px;
  color: var(--ink-soft);
  line-height: 1.45;
}

.item-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.tag {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  background: #f5f5f4;
  color: var(--ink-soft);
}

.tag.cat-spot { background: #ecfdf5; color: #047857; }
.tag.cat-food { background: #fff7ed; color: #c2410c; }
.tag.cat-hotel { background: #eff6ff; color: #1d4ed8; }
.tag.cat-move { background: #f5f3ff; color: #6d28d9; }
.tag.cat-shop { background: #fdf2f8; color: #be185d; }
.tag.cost { background: var(--teal-soft); color: var(--teal-deep); }

.item-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.item-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--teal-deep);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.item-link:active {
  transform: scale(0.98);
  background: var(--teal-soft);
}

.item-link.map {
  border-color: #99f6e4;
  background: #f0fdfa;
}

.item-link.info {
  border-color: #fecdd3;
  background: #fff1f2;
  color: #9f1239;
}

.field-hint {
  margin: -4px 0 12px;
  font-size: 11px;
  color: var(--ink-soft);
  line-height: 1.45;
}

/* Bottom nav */
.bottom-nav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: var(--max);
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr 56px;
  gap: 2px;
  padding: 10px 8px calc(10px + var(--safe-b));
  background: rgba(246, 243, 238, 0.92);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  z-index: 20;
}

.wishlist-banner {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 14px 12px;
  margin-bottom: 14px;
  box-shadow: 0 4px 12px rgba(28, 25, 23, 0.04);
}

.wishlist-title {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 700;
}

.wishlist-sub {
  margin: 0;
  font-size: 12px;
  color: var(--ink-soft);
  line-height: 1.5;
}

.wishlist-list {
  display: grid;
  gap: 10px;
}

.wish-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: 0 4px 12px rgba(28, 25, 23, 0.04);
}

.wish-card h3 {
  margin: 0 0 4px;
  font-size: 15px;
  line-height: 1.35;
}

.wish-meta {
  margin: 0;
  font-size: 12px;
  color: var(--ink-soft);
  line-height: 1.45;
}

.wish-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  align-items: center;
}

.vote-btn {
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid #fecdd3;
  background: #fff1f2;
  color: #9f1239;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.vote-btn.on {
  background: #e11d48;
  border-color: #e11d48;
  color: #fff;
}

.btn-mini {
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--teal-deep);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.btn-mini.primary {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
}

.check-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--teal);
}

.nav-btn {
  border: none;
  background: transparent;
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-soft);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 4px;
  border-radius: 12px;
  cursor: pointer;
}

.nav-btn span {
  font-size: 18px;
  line-height: 1;
}

.nav-btn.active {
  color: var(--teal-deep);
  background: var(--teal-soft);
}

.nav-add {
  background: linear-gradient(180deg, #0f766e, #0d5f59) !important;
  color: #fff !important;
  border-radius: 16px !important;
  justify-content: center;
}

.nav-add .plus {
  font-size: 28px;
  font-weight: 500;
  line-height: 1;
}

/* Sheet */
.sheet {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: var(--max);
  background: var(--bg-elev);
  border-radius: 22px 22px 0 0;
  padding: 10px 16px calc(20px + var(--safe-b));
  box-shadow: 0 -12px 40px rgba(28, 25, 23, 0.18);
  z-index: 40;
  max-height: 78dvh;
  overflow: auto;
}

.sheet.hidden {
  display: none;
}

.sheet-handle {
  width: 42px;
  height: 4px;
  border-radius: 999px;
  background: #d6d3d1;
  margin: 4px auto 14px;
}

.sheet h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

.sheet textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  font: inherit;
  font-size: 14px;
  resize: vertical;
  min-height: 140px;
  margin-bottom: 12px;
  background: var(--sand);
}

.member-list {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: grid;
  gap: 8px;
}

.member-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--sand);
  border: 1px solid var(--line);
}

.member-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--teal);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
}

.hint {
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--ink-soft);
  line-height: 1.5;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(28, 25, 23, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
  padding: 0;
}

.modal.hidden {
  display: none;
}

.modal-card {
  width: 100%;
  max-width: var(--max);
  background: var(--bg-elev);
  border-radius: 22px 22px 0 0;
  padding: 20px 16px calc(20px + var(--safe-b));
  box-shadow: var(--shadow);
}

.modal-scroll {
  max-height: 88dvh;
  overflow: auto;
}

.modal-card h2 {
  margin: 0 0 14px;
  font-size: 18px;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.field span {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
}

.field em {
  color: var(--coral);
  font-style: normal;
}

.field input,
.field select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 12px;
  font: inherit;
  font-size: 15px;
  background: #fff;
  color: var(--ink);
}

.field input:focus,
.field select:focus,
.sheet textarea:focus {
  outline: 2px solid rgba(15, 118, 110, 0.35);
  border-color: var(--teal);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.code-input {
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-weight: 700;
  font-size: 20px !important;
  text-align: center;
}

.code-display {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-align: center;
  padding: 18px;
  margin: 8px 0 16px;
  background: var(--teal-soft);
  color: var(--teal-deep);
  border-radius: 16px;
}

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

.modal-actions .btn {
  flex: 1;
}

.error {
  margin: 0 0 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fff1f2;
  color: var(--coral);
  font-size: 13px;
}

.error.hidden {
  display: none;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + var(--safe-b));
  transform: translateX(-50%);
  max-width: calc(var(--max) - 32px);
  background: #1c1917;
  color: #fff;
  padding: 12px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  z-index: 60;
  box-shadow: var(--shadow);
}

.toast.hidden {
  display: none;
}

@media (min-width: 480px) {
  .modal {
    align-items: center;
    padding: 20px;
  }

  .modal-card {
    border-radius: 22px;
  }
}
