:root {
  --ink: #17150e;
  --ink-soft: #4f4936;
  --sun: #f7c928;
  --sun-bright: #ffdd4a;
  --sun-pale: #fff4b8;
  --cream: #fffaf0;
  --paper: rgba(255, 253, 246, 0.92);
  --orange: #ff9f1c;
  --green: #1f6b45;
  --red: #b93b24;
  --line: rgba(63, 52, 18, 0.14);
  --shadow: 0 28px 70px rgba(79, 57, 0, 0.16);
  --radius-xl: 34px;
  --radius-lg: 24px;
  --radius-md: 18px;
  --safe-top: max(18px, env(safe-area-inset-top));
  --safe-bottom: max(24px, env(safe-area-inset-bottom));
}

* { box-sizing: border-box; }

html, body { width: 100%; max-width: 100%; }

img, svg { max-width: 100%; }

html {
  min-height: 100%;
  background: #f5c51d;
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 4%, rgba(255, 250, 217, 0.95) 0 10%, transparent 38%),
    radial-gradient(circle at 92% 18%, rgba(255, 154, 26, 0.28), transparent 32%),
    linear-gradient(145deg, #ffd83f 0%, #f2bd19 55%, #e9a80a 100%);
  font-family: "Manrope", "Trebuchet MS", sans-serif;
  overflow-x: hidden;
}

button, input { font: inherit; }
button { color: inherit; }

.noise {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.18;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.18'/%3E%3C/svg%3E");
}

.ambient {
  position: fixed;
  z-index: -2;
  border-radius: 999px;
  filter: blur(8px);
  pointer-events: none;
  animation: drift 12s ease-in-out infinite alternate;
}

.ambient-one {
  width: 420px;
  height: 420px;
  top: -210px;
  right: -120px;
  background: rgba(255, 245, 170, 0.55);
}

.ambient-two {
  width: 360px;
  height: 360px;
  bottom: -220px;
  left: -140px;
  background: rgba(255, 135, 22, 0.25);
  animation-delay: -4s;
}

.app-shell {
  width: min(1180px, 100%);
  min-height: 100vh;
  min-height: 100svh;
  margin: 0 auto;
  padding: var(--safe-top) clamp(16px, 4vw, 42px) var(--safe-bottom);
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  animation: rise-in 0.55s ease-out both;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.brand-mark,
.loader-logo {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 15px;
  color: var(--sun-bright);
  background: var(--ink);
  box-shadow: 0 8px 0 rgba(255, 255, 255, 0.45);
  font-family: "Unbounded", sans-serif;
  font-weight: 800;
  overflow: hidden;
}

.brand-mark img,
.loader-logo img { width: 100%; height: 100%; object-fit: cover; }

.brand-copy { display: grid; line-height: 1.05; }
.brand-copy strong { font-family: "Unbounded", sans-serif; font-size: 16px; letter-spacing: 0.05em; }
.brand-copy small { margin-top: 5px; color: var(--ink-soft); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  padding: 7px 12px 7px 7px;
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 999px;
  background: rgba(255, 250, 225, 0.58);
  backdrop-filter: blur(14px);
}

.user-avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 50%;
  color: #fff8d6;
  background: var(--ink);
  font-weight: 800;
}

.user-meta { min-width: 0; display: grid; }
.user-meta small { color: var(--ink-soft); font-size: 9px; }
.user-meta strong { max-width: 132px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }

.main {
  width: 100%;
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: center;
  padding: clamp(34px, 7vh, 76px) 0 46px;
}

.loader-card {
  width: min(420px, 100%);
  margin: auto;
  padding: 34px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: var(--radius-xl);
  background: var(--paper);
  box-shadow: var(--shadow);
  text-align: center;
}

.loader-logo { margin: 0 auto 24px; animation: loader-pulse 1.2s ease-in-out infinite; }
.loader-line { height: 6px; overflow: hidden; border-radius: 999px; background: #eee4bb; }
.loader-line span { display: block; width: 45%; height: 100%; border-radius: inherit; background: var(--sun); animation: loading 1s ease-in-out infinite alternate; }
.loader-card p { margin: 14px 0 0; color: var(--ink-soft); font-size: 13px; }

.home-view,
.wizard-view,
.result-view,
.error-view {
  width: 100%;
  animation: page-enter 0.5s cubic-bezier(.2,.8,.2,1) both;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(260px, .55fr);
  align-items: end;
  gap: 30px;
  margin-bottom: clamp(28px, 5vw, 46px);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 15px;
  color: #5e4b0b;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.eyebrow::before { content: ""; width: 28px; height: 2px; border-radius: 9px; background: currentColor; }

.hero h1,
.wizard-title,
.result-title {
  margin: 0;
  font-family: "Unbounded", sans-serif;
  font-size: clamp(32px, 6.4vw, 74px);
  line-height: 0.98;
  letter-spacing: -0.045em;
}

.hero h1 span { display: block; color: rgba(23, 21, 14, 0.57); }
.hero-copy { max-width: 680px; margin: 22px 0 0; color: var(--ink-soft); font-size: clamp(15px, 2vw, 18px); line-height: 1.62; }

.market-card {
  position: relative;
  overflow: hidden;
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 28px;
  background: rgba(255, 247, 201, 0.63);
  box-shadow: 0 18px 45px rgba(89, 59, 0, 0.12);
  backdrop-filter: blur(16px);
}

.market-card::after {
  content: "¥";
  position: absolute;
  right: -15px;
  bottom: -42px;
  color: rgba(23, 21, 14, 0.07);
  font-family: "Unbounded", sans-serif;
  font-size: 128px;
  font-weight: 800;
}

.market-card > * { position: relative; z-index: 1; }
.market-label { margin: 0 0 18px; font-size: 11px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.rate-value { display: flex; align-items: baseline; gap: 7px; margin-bottom: 18px; }
.rate-value strong { font-family: "Unbounded", sans-serif; font-size: 38px; }
.rate-value span { font-weight: 800; }
.market-meta { display: grid; gap: 9px; }
.market-meta div { display: flex; justify-content: space-between; gap: 16px; font-size: 12px; }
.market-meta span { color: var(--ink-soft); }

.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.section-heading h2 { margin: 0; font-family: "Unbounded", sans-serif; font-size: clamp(20px, 3vw, 28px); }
.section-heading p { max-width: 440px; margin: 0; color: var(--ink-soft); font-size: 13px; text-align: right; }

.tariff-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.tariff-card {
  position: relative;
  min-height: 260px;
  padding: 22px;
  border: 1px solid rgba(61, 49, 14, 0.11);
  border-radius: 28px;
  background: rgba(255, 253, 244, 0.92);
  box-shadow: 0 15px 38px rgba(71, 49, 0, 0.1);
  cursor: pointer;
  text-align: left;
  transition: transform .3s ease, box-shadow .3s ease, background .3s ease;
  animation: card-in .55s cubic-bezier(.2,.8,.2,1) both;
}

.tariff-card:nth-child(2) { animation-delay: .08s; }
.tariff-card:nth-child(3) { animation-delay: .16s; }
.tariff-card:hover { transform: translateY(-7px) rotate(-.25deg); background: #fffdf7; box-shadow: 0 24px 55px rgba(71, 49, 0, 0.16); }
.tariff-card:active { transform: translateY(-1px) scale(.985); }
.tariff-card.featured { color: #fff8dc; background: var(--ink); }
.tariff-card.featured .tariff-description, .tariff-card.featured .tariff-kicker { color: rgba(255, 248, 220, .66); }

.tariff-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; }
.tariff-number { font-family: "Unbounded", sans-serif; font-size: 11px; font-weight: 800; opacity: .48; }
.tariff-icon { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 18px; background: var(--sun); font-size: 25px; transform: rotate(3deg); }
.tariff-card h3 { margin: 34px 0 7px; font-family: "Unbounded", sans-serif; font-size: clamp(19px, 2.4vw, 26px); }
.tariff-kicker { margin: 0 0 12px; color: #88711c; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.tariff-description { margin: 0; color: var(--ink-soft); font-size: 13px; line-height: 1.55; }
.tariff-arrow { position: absolute; right: 22px; bottom: 20px; font-size: 22px; transition: transform .25s ease; }
.tariff-card:hover .tariff-arrow { transform: translateX(5px); }

.wizard-view { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 22px; align-items: start; }
.wizard-view,
.wizard-card,
.side-panel,
.summary-list,
.option-grid,
.option-card,
.wizard-actions,
.result-card { min-width: 0; max-width: 100%; }
.wizard-card,
.side-panel,
.result-card {
  border: 1px solid rgba(255, 255, 255, .78);
  background: var(--paper);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.wizard-card { min-height: 560px; padding: clamp(22px, 4vw, 42px); border-radius: var(--radius-xl); }
.wizard-head { margin-bottom: 30px; }
.progress-row { display: flex; align-items: center; gap: 14px; margin-bottom: 26px; }
.progress-track { height: 7px; flex: 1; overflow: hidden; border-radius: 999px; background: #eee6c5; }
.progress-bar { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--orange), var(--sun)); transition: width .45s cubic-bezier(.2,.8,.2,1); }
.progress-label { min-width: 54px; color: var(--ink-soft); font-size: 11px; font-weight: 800; text-align: right; }
.wizard-title { font-size: clamp(26px, 4vw, 46px); line-height: 1.08; }
.wizard-title,
.wizard-help,
.option-copy strong,
.option-copy small,
.summary-item strong { overflow-wrap: anywhere; }
.wizard-help { max-width: 660px; margin: 14px 0 0; color: var(--ink-soft); font-size: 14px; line-height: 1.55; }

.field-wrap { animation: step-enter .38s ease-out both; }
.field-label { display: block; margin-bottom: 11px; font-size: 12px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.number-field { position: relative; }
.number-field input {
  width: 100%;
  height: 76px;
  padding: 0 78px 0 20px;
  border: 2px solid transparent;
  border-radius: 22px;
  outline: none;
  color: var(--ink);
  background: #fff9d8;
  font-family: "Unbounded", sans-serif;
  font-size: clamp(24px, 5vw, 36px);
  font-weight: 700;
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
.number-field input:focus { border-color: var(--orange); background: #fffdf4; box-shadow: 0 0 0 5px rgba(255, 159, 28, .14); }
.number-unit { position: absolute; right: 20px; top: 50%; transform: translateY(-50%); color: #806816; font-weight: 800; }
.field-note { display: flex; align-items: flex-start; gap: 8px; margin: 12px 0 0; color: var(--ink-soft); font-size: 12px; line-height: 1.5; }
.field-note strong { color: var(--ink); }

.quick-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.quick-button { padding: 9px 13px; border: 1px solid var(--line); border-radius: 999px; background: #fff; cursor: pointer; font-size: 12px; font-weight: 800; transition: .2s ease; }
.quick-button:hover { border-color: var(--orange); background: var(--sun-pale); }

.item-manager { display: grid; gap: 16px; animation: step-enter .38s ease-out both; }
.item-list { display: grid; gap: 9px; }
.item-line {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fffdf7;
}
.item-line-icon { display: grid; place-items: center; width: 42px; height: 42px; flex: 0 0 auto; border-radius: 13px; background: var(--sun-pale); font-size: 20px; }
.item-line-copy { min-width: 0; flex: 1; display: grid; gap: 3px; }
.item-line-copy strong { overflow-wrap: anywhere; font-size: 12px; }
.item-line-copy small { color: var(--ink-soft); font-size: 10px; line-height: 1.4; }
.item-remove { width: 34px; height: 34px; flex: 0 0 auto; border: 0; border-radius: 50%; color: var(--red); background: #ffe8dc; cursor: pointer; font-size: 22px; line-height: 1; }
.item-manager-actions { display: flex; gap: 10px; }
.item-manager-actions .button-primary { flex: 1; }

.option-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; animation: step-enter .38s ease-out both; }
.option-card {
  display: flex;
  align-items: center;
  gap: 13px;
  min-height: 76px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 19px;
  background: #fffdf7;
  cursor: pointer;
  text-align: left;
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
.option-card:hover { transform: translateY(-2px); border-color: #d29d00; box-shadow: 0 10px 24px rgba(72, 52, 0, .1); }
.option-card.selected { border-color: var(--ink); background: var(--sun-pale); box-shadow: inset 0 0 0 1px var(--ink); }
.option-icon { display: grid; place-items: center; width: 43px; height: 43px; flex: 0 0 auto; border-radius: 14px; background: var(--sun-pale); font-size: 21px; }
.option-card.selected .option-icon { background: var(--sun); }
.option-copy { min-width: 0; display: grid; gap: 3px; }
.option-copy strong { font-size: 13px; line-height: 1.25; }
.option-copy small { color: var(--ink-soft); font-size: 10px; line-height: 1.35; }

.wizard-actions { display: flex; gap: 10px; margin-top: 28px; }
.button {
  min-height: 52px;
  padding: 0 20px;
  border: 0;
  border-radius: 17px;
  cursor: pointer;
  font-weight: 800;
  transition: transform .2s ease, box-shadow .2s ease, opacity .2s ease;
}
.button:active { transform: scale(.975); }
.button-primary { flex: 1; color: #fff8d6; background: var(--ink); box-shadow: 0 10px 22px rgba(23, 21, 14, .2); }
.button-primary:hover { transform: translateY(-2px); box-shadow: 0 14px 28px rgba(23, 21, 14, .25); }
.button-secondary { background: #f4edcf; }
.button-ghost { background: transparent; border: 1px solid var(--line); }
.button[disabled] { opacity: .45; cursor: not-allowed; transform: none; }

.side-panel { position: sticky; top: 20px; padding: 22px; border-radius: 26px; }
.side-panel h3 { margin: 0 0 18px; font-family: "Unbounded", sans-serif; font-size: 16px; }
.summary-list { display: grid; gap: 12px; }
.summary-item { padding-bottom: 12px; border-bottom: 1px dashed var(--line); }
.summary-item:last-child { padding-bottom: 0; border: 0; }
.summary-item small { display: block; margin-bottom: 4px; color: var(--ink-soft); font-size: 9px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.summary-item strong { font-size: 12px; line-height: 1.4; }
.side-tip { margin: 18px 0 0; padding: 13px; border-radius: 15px; color: #634d00; background: var(--sun-pale); font-size: 11px; line-height: 1.5; }

.result-view { max-width: 880px; margin: 0 auto; }
.result-card { position: relative; overflow: hidden; padding: clamp(24px, 5vw, 48px); border-radius: var(--radius-xl); }
.result-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 8px; background: linear-gradient(90deg, var(--orange), var(--sun), #ffe989); }
.result-head { display: flex; justify-content: space-between; gap: 22px; align-items: flex-start; margin-bottom: 28px; }
.result-title { font-size: clamp(28px, 5vw, 50px); }
.result-badge { padding: 9px 13px; border-radius: 999px; color: var(--green); background: #dff5df; font-size: 10px; font-weight: 800; white-space: nowrap; text-transform: uppercase; letter-spacing: .07em; }
.total-block { display: flex; justify-content: space-between; align-items: end; gap: 16px; padding: 22px; border-radius: 24px; background: var(--ink); color: #fff8d6; }
.total-block small { display: block; margin-bottom: 7px; color: rgba(255, 248, 214, .62); font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.total-value { font-family: "Unbounded", sans-serif; font-size: clamp(29px, 6vw, 50px); line-height: 1; }
.total-mark { color: var(--sun); font-family: "Unbounded", sans-serif; font-size: 22px; }
.result-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
.result-row { display: flex; justify-content: space-between; gap: 14px; padding: 15px; border-radius: 17px; background: #f7f1d9; font-size: 12px; }
.result-row span { color: var(--ink-soft); }
.result-row strong { text-align: right; }
.result-row.full { grid-column: 1 / -1; }
.result-alert { margin-top: 14px; padding: 15px; border-radius: 17px; color: #755700; background: #fff0a4; font-size: 12px; line-height: 1.5; }
.result-actions { display: flex; gap: 10px; margin-top: 18px; }

.error-view { max-width: 560px; margin: auto; padding: 32px; border-radius: var(--radius-xl); background: var(--paper); box-shadow: var(--shadow); text-align: center; }
.error-icon { font-size: 42px; }
.error-view h1 { margin: 12px 0 8px; font-family: "Unbounded", sans-serif; font-size: 24px; }
.error-view p { margin: 0 0 20px; color: var(--ink-soft); line-height: 1.55; }

.footer { display: flex; justify-content: space-between; gap: 16px; color: rgba(23, 21, 14, .53); font-size: 9px; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }

.toast {
  position: fixed;
  z-index: 30;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  max-width: calc(100% - 32px);
  padding: 12px 17px;
  border-radius: 999px;
  color: #fff8d6;
  background: var(--ink);
  box-shadow: 0 15px 35px rgba(0,0,0,.24);
  font-size: 12px;
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 18px);
  transition: opacity .25s ease, transform .25s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@keyframes page-enter { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes rise-in { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: none; } }
@keyframes card-in { from { opacity: 0; transform: translateY(18px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes step-enter { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }
@keyframes loading { from { transform: translateX(-40%); } to { transform: translateX(170%); } }
@keyframes loader-pulse { 50% { transform: translateY(-5px) rotate(-2deg); } }
@keyframes drift { to { transform: translate3d(40px, 22px, 0) scale(1.08); } }

@media (max-width: 820px) {
  .hero { grid-template-columns: 1fr; align-items: start; }
  .market-card { width: 100%; }
  .tariff-grid { grid-template-columns: 1fr; }
  .tariff-card { min-height: 205px; }
  .tariff-card h3 { margin-top: 24px; }
  .wizard-view { grid-template-columns: 1fr; }
  .side-panel { position: static; order: -1; padding: 16px 18px; }
  .side-panel h3 { margin-bottom: 11px; font-size: 13px; }
  .summary-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; overflow: hidden; }
  .summary-item { min-width: 0; padding: 10px 12px; border: 0; border-radius: 13px; background: #f7f0d3; }
  .side-tip { display: none; }
}

@media (max-width: 680px) {
  .app-shell { padding-left: 13px; padding-right: 13px; }
  .brand-copy small, .user-meta small { display: none; }
  .brand-mark { width: 41px; height: 41px; border-radius: 13px; }
  .user-chip { padding-right: 9px; }
  .user-meta strong { max-width: 92px; }
  .main { align-items: flex-start; padding-top: 34px; }
  .hero h1 { font-size: clamp(34px, 12vw, 52px); }
  .section-heading { align-items: flex-start; flex-direction: column; gap: 7px; }
  .section-heading p { text-align: left; }
  .wizard-card { min-height: 0; padding: 22px 16px; border-radius: 27px; }
  .wizard-title { font-size: clamp(25px, 8vw, 38px); letter-spacing: -0.055em; }
  .wizard-help { font-size: 13px; }
  .option-grid { grid-template-columns: 1fr; }
  .option-card { min-height: 68px; }
  .wizard-actions, .result-actions { flex-wrap: wrap; }
  .item-manager-actions { flex-direction: column; }
  .item-manager-actions .button-primary { order: initial; }
  .wizard-actions > *, .result-actions > * { min-width: 0; }
  .button-secondary, .button-ghost { flex: 1; }
  .button-primary { flex-basis: 100%; order: -1; }
  .result-head { flex-direction: column; }
  .result-grid { grid-template-columns: 1fr; }
  .result-row.full { grid-column: auto; }
  .total-block { align-items: flex-start; flex-direction: column; }
  .footer { flex-direction: column; align-items: center; text-align: center; }
}

@media (max-width: 420px) {
  .summary-list { grid-template-columns: 1fr; }
  .topbar { gap: 8px; }
  .brand { gap: 8px; }
  .brand-copy strong { font-size: 14px; }
  .user-meta strong { max-width: 76px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
