:root {
  --bg: #f7f3eb;
  --bg-soft: #fcfaf5;
  --surface: rgba(255, 252, 246, 0.88);
  --surface-strong: #fffdf8;
  --ink: #3c342b;
  --ink-soft: #786d61;
  --line: rgba(123, 103, 82, 0.16);
  --accent: #7c9a84;
  --accent-strong: #5d7d67;
  --tone-sage-bg: #e5ede3;
  --tone-sage-ink: #748a76;
  --tone-sand-bg: #ede4d8;
  --tone-sand-ink: #9a8267;
  --tone-peach-bg: #f1e1d8;
  --tone-peach-ink: #a07f73;
  --wood: #c7ae8f;
  --peach: #eecab1;
  --shadow: 0 24px 60px rgba(97, 73, 42, 0.08);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-pill: 999px;
  --font-ui: "Avenir Next", "Hiragino Sans", "Yu Gothic", "Noto Sans TC",
    sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-ui);
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.8), transparent 36%),
    linear-gradient(180deg, #f8f4ec 0%, #f5efe6 44%, #f1eadf 100%);
}

button,
input,
select {
  font: inherit;
}

.background-ornament {
  position: fixed;
  width: 32rem;
  height: 32rem;
  border-radius: 50%;
  filter: blur(18px);
  opacity: 0.48;
  z-index: 0;
  pointer-events: none;
}

.background-ornament-left {
  top: -10rem;
  left: -10rem;
  background: radial-gradient(circle, rgba(238, 202, 177, 0.9), transparent 62%);
}

.background-ornament-right {
  bottom: -12rem;
  right: -8rem;
  background: radial-gradient(circle, rgba(182, 210, 193, 0.85), transparent 64%);
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1120px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.35rem 0 2rem;
}

.hero-card,
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.hero-card {
  overflow: hidden;
  position: relative;
  padding: 1.25rem 1.4rem;
  margin-bottom: 0.85rem;
}

.hero-card::after {
  content: "";
  position: absolute;
  inset: auto -4rem -4rem auto;
  width: 14rem;
  height: 14rem;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(199, 174, 143, 0.28), transparent 64%);
}

.eyebrow,
.section-kicker {
  margin: 0 0 0.35rem;
  color: var(--accent-strong);
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2.1rem, 4vw, 3.8rem);
  line-height: 1.06;
  letter-spacing: 0.02em;
}

.hero-title {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 1rem;
}

.hero-title-icon {
  display: block;
  width: clamp(3.25rem, 5.4vw, 4.25rem);
  height: clamp(3.25rem, 5.4vw, 4.25rem);
  flex-shrink: 0;
  border-radius: 1.15rem;
  box-shadow: 0 14px 30px rgba(107, 86, 58, 0.1);
}

h2 {
  font-size: clamp(1.35rem, 2vw, 1.85rem);
}

.panel {
  padding: 1rem;
  margin-bottom: 0.85rem;
}

.panel-header {
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  align-items: start;
  margin-bottom: 0.8rem;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.7rem;
}

.category-card,
.recent-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(255, 253, 248, 0.95), rgba(248, 242, 232, 0.95));
  padding: 0.85rem;
  text-align: left;
  color: inherit;
  box-shadow: 0 12px 30px rgba(80, 60, 32, 0.04);
  cursor: pointer;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    border-color 180ms ease;
}

.category-card:hover,
.recent-card:hover,
.category-card:focus-visible,
.recent-card:focus-visible {
  transform: translateY(-3px);
  box-shadow: 0 16px 40px rgba(80, 60, 32, 0.09);
  border-color: rgba(124, 154, 132, 0.3);
  outline: none;
}

.category-icon {
  width: 2.8rem;
  height: 2.8rem;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  margin-bottom: 0.55rem;
  color: var(--accent-strong);
}

.category-icon-sage {
  background: var(--tone-sage-bg);
  color: var(--tone-sage-ink);
}

.category-icon-sand {
  background: var(--tone-sand-bg);
  color: var(--tone-sand-ink);
}

.category-icon-peach {
  background: var(--tone-peach-bg);
  color: var(--tone-peach-ink);
}

.category-icon-svg {
  width: 1.45rem;
  height: 1.45rem;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.card-title {
  font-size: 0.96rem;
  font-weight: 700;
}

.recent-meta,
.empty-state,
.result-sub {
  margin-top: 0.35rem;
  color: var(--ink-soft);
  line-height: 1.6;
}

.recent-list {
  display: grid;
  gap: 0.6rem;
}

.recent-card {
  width: 100%;
}

.recent-main {
  display: flex;
  gap: 0.8rem;
  justify-content: space-between;
  align-items: center;
}

.panel-recent .ghost-button {
  flex-shrink: 0;
}

.recent-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.28rem 0.56rem;
  border-radius: var(--radius-pill);
  background: rgba(124, 154, 132, 0.12);
  color: var(--accent-strong);
  font-size: 0.8rem;
}

.converter-form {
  display: grid;
  gap: 0.85rem;
}

.field {
  display: grid;
  gap: 0.35rem;
  font-weight: 600;
}

.field span {
  color: var(--ink-soft);
  font-size: 0.95rem;
}

input,
select {
  width: 100%;
  min-height: 3rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(123, 103, 82, 0.18);
  background: var(--surface-strong);
  padding: 0.72rem 0.9rem;
  color: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

input:focus,
select:focus {
  outline: 2px solid rgba(124, 154, 132, 0.23);
  border-color: rgba(124, 154, 132, 0.42);
}

.unit-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.6rem;
  align-items: end;
}

.swap-button,
.text-button,
.ghost-button {
  border: 0;
  cursor: pointer;
}

.swap-button {
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  background: linear-gradient(180deg, #dfeadf, #cfe0d2);
  color: var(--accent-strong);
  font-size: 1.2rem;
  box-shadow: 0 10px 24px rgba(93, 125, 103, 0.16);
}

.text-button {
  margin-bottom: 0.45rem;
  padding: 0;
  background: transparent;
  color: var(--accent-strong);
  font-weight: 700;
}

.ghost-button {
  padding: 0.48rem 0.82rem;
  border-radius: var(--radius-pill);
  background: rgba(124, 154, 132, 0.12);
  color: var(--accent-strong);
  font-weight: 700;
}

.result-card {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(255, 254, 251, 0.95), rgba(246, 239, 230, 0.95));
  border: 1px solid rgba(123, 103, 82, 0.15);
}

.result-main {
  margin-top: 0.2rem;
  font-size: clamp(1.35rem, 3vw, 2rem);
  line-height: 1.3;
  font-weight: 800;
}

.hidden {
  display: none !important;
}

@media (min-width: 920px) {
  .app-shell {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.9fr);
    gap: 0.85rem;
    align-items: start;
  }

  .hero-card,
  .panel-converter {
    grid-column: 1 / -1;
  }

  .panel-home,
  .panel-recent {
    margin-bottom: 0;
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 1rem, 40rem);
    padding-top: 1rem;
  }

  .hero-card,
  .panel {
    padding: 1rem;
    border-radius: 24px;
  }

  .hero-title {
    gap: 0.75rem;
  }

  .hero-title-icon {
    width: 2.9rem;
    height: 2.9rem;
    border-radius: 0.95rem;
  }

  .panel-header,
  .recent-main {
    flex-direction: column;
    align-items: start;
  }

  .panel-recent .ghost-button {
    align-self: flex-start;
  }

  .unit-row {
    grid-template-columns: 1fr;
  }

  .swap-button {
    justify-self: center;
  }
}
