:root {
  --bg: #f8f2e8;
  --bg-accent: #f1dcc2;
  --surface: rgba(255, 250, 244, 0.8);
  --surface-strong: #fffdf9;
  --ink: #2f241e;
  --muted: #725f53;
  --line: rgba(123, 91, 63, 0.16);
  --brand: #b96f3e;
  --brand-dark: #8d5029;
  --shadow: 0 22px 60px rgba(100, 68, 43, 0.12);
  --hero-surface: linear-gradient(145deg, rgba(255, 251, 246, 0.92), rgba(255, 244, 228, 0.82));
  --summary-surface: linear-gradient(150deg, rgba(255, 250, 244, 0.9), rgba(249, 236, 218, 0.85));
  --panel-fill: rgba(255, 252, 247, 0.85);
  --panel-soft: rgba(255, 248, 239, 0.8);
  --control-fill: rgba(255, 255, 255, 0.78);
  --toggle-fill: rgba(255, 248, 239, 0.88);
  --toggle-line: rgba(123, 91, 63, 0.16);
}

:root[data-theme="dark"] {
  --bg: #16120f;
  --bg-accent: #2e241d;
  --surface: rgba(37, 30, 25, 0.86);
  --surface-strong: #2b221d;
  --ink: #f7eee4;
  --muted: #d0b8a5;
  --line: rgba(228, 194, 164, 0.14);
  --brand: #e6a16d;
  --brand-dark: #ffd7b8;
  --shadow: 0 24px 65px rgba(0, 0, 0, 0.34);
  --hero-surface: linear-gradient(145deg, rgba(50, 39, 32, 0.95), rgba(31, 24, 20, 0.9));
  --summary-surface: linear-gradient(150deg, rgba(52, 41, 34, 0.92), rgba(32, 26, 22, 0.88));
  --panel-fill: rgba(42, 34, 28, 0.92);
  --panel-soft: rgba(51, 41, 34, 0.92);
  --control-fill: rgba(27, 22, 18, 0.88);
  --toggle-fill: rgba(51, 40, 32, 0.92);
  --toggle-line: rgba(228, 194, 164, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  font-family: "Pretendard", "Noto Sans KR", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top right, rgba(255, 255, 255, 0.7), transparent 32%),
    radial-gradient(circle at left 20%, rgba(241, 220, 194, 0.8), transparent 24%),
    linear-gradient(135deg, var(--bg), #fef9f1 55%, #f8ecdc);
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: auto;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(10px);
}

body::before {
  top: 6%;
  right: 8%;
  width: 220px;
  height: 220px;
  background: rgba(245, 204, 160, 0.3);
}

body::after {
  bottom: 12%;
  left: 6%;
  width: 280px;
  height: 280px;
  background: rgba(193, 140, 84, 0.12);
}

:root[data-theme="dark"] body {
  background:
    radial-gradient(circle at top right, rgba(230, 161, 109, 0.12), transparent 32%),
    radial-gradient(circle at left 20%, rgba(93, 69, 53, 0.35), transparent 24%),
    linear-gradient(135deg, #110e0c, #1c1612 55%, #261d18);
}

:root[data-theme="dark"] body::before {
  background: rgba(230, 161, 109, 0.1);
}

:root[data-theme="dark"] body::after {
  background: rgba(132, 96, 71, 0.12);
}

.page-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 40px 0 56px;
}

.hero {
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 32px;
  background: var(--hero-surface);
  box-shadow: var(--shadow);
  animation: rise 0.7s ease-out both;
}

.hero-topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 10px;
  color: var(--brand-dark);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--toggle-line);
  width: 46px;
  height: 46px;
  padding: 0;
  border-radius: 50%;
  background: var(--toggle-fill);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  transition: transform 0.25s ease, border-color 0.25s ease, background-color 0.25s ease, box-shadow 0.25s ease;
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(185, 111, 62, 0.38);
  box-shadow: 0 10px 22px rgba(100, 68, 43, 0.12);
}

.theme-toggle-icon {
  display: block;
  font-size: 1.15rem;
  line-height: 1;
}

.hero h1,
.panel-head h2 {
  margin: 0;
  font-family: "Iropke Batang", "Noto Serif KR", serif;
  line-height: 1.2;
}

.hero h1 {
  max-width: 700px;
  font-size: clamp(2rem, 5vw, 4.2rem);
  text-wrap: balance;
}

.hero-copy {
  margin: 18px 0 0;
  max-width: 620px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.7;
}

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(320px, 1.05fr);
  gap: 20px;
  margin-top: 20px;
}

.panel {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--surface);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
}

.form-panel {
  animation: rise 0.9s ease-out both;
}

.result-panel {
  animation: rise 1.1s ease-out both;
}

.contact-panel {
  margin-top: 20px;
  animation: rise 1.25s ease-out both;
}

.contact-copy {
  margin: 0 0 18px;
  max-width: 720px;
  color: var(--muted);
  line-height: 1.7;
}

.contact-form {
  display: grid;
  gap: 14px;
}

.panel-head {
  margin-bottom: 18px;
}

.panel-head h2 {
  font-size: clamp(1.4rem, 3vw, 2rem);
}

.naming-form {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 8px;
  font-size: 0.96rem;
  font-weight: 600;
}

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

input,
select,
textarea,
.primary-button {
  width: 100%;
  min-width: 0;
  border-radius: 18px;
  font: inherit;
}

input,
select,
textarea {
  padding: 14px 16px;
  border: 1px solid rgba(123, 91, 63, 0.22);
  background: var(--control-fill);
  color: var(--ink);
  outline: none;
  transition: border-color 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease;
}

input[type="date"],
input[type="time"] {
  width: 100%;
  max-width: 100%;
  min-height: 52px;
  padding-right: 12px;
  line-height: 1.2;
  appearance: none;
  -webkit-appearance: none;
}

input[type="date"]::-webkit-datetime-edit,
input[type="time"]::-webkit-datetime-edit {
  padding: 0;
}

input[type="date"]::-webkit-date-and-time-value,
input[type="time"]::-webkit-date-and-time-value {
  min-width: 0;
  margin: 0;
  text-align: left;
}

input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator {
  margin: 0;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(185, 111, 62, 0.7);
  box-shadow: 0 0 0 4px rgba(185, 111, 62, 0.12);
  transform: translateY(-1px);
}

textarea {
  resize: vertical;
  min-height: 110px;
}

.primary-button {
  min-height: 54px;
  margin-top: 4px;
  padding: 15px 18px;
  border: 0;
  background: linear-gradient(135deg, var(--brand), #d18a58);
  color: #fff9f3;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 14px 30px rgba(185, 111, 62, 0.24);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.primary-button:hover,
.primary-button:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 18px 34px rgba(185, 111, 62, 0.32);
}

.summary-card {
  min-height: 136px;
  padding: 18px;
  border-radius: 22px;
  background: var(--summary-surface);
  border: 1px solid rgba(123, 91, 63, 0.14);
}

.summary-card h3 {
  margin: 0 0 10px;
  font-family: "Iropke Batang", "Noto Serif KR", serif;
  font-size: 1.2rem;
}

.summary-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.recommendation-list {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.name-card {
  cursor: pointer;
  padding: 18px;
  border-radius: 22px;
  background: var(--surface-strong);
  border: 1px solid rgba(123, 91, 63, 0.14);
  transform: translateY(16px);
  opacity: 0;
  animation: card-in 0.55s ease forwards;
  transition: border-color 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease;
}

.name-card:nth-child(2) {
  animation-delay: 0.08s;
}

.name-card:nth-child(3) {
  animation-delay: 0.16s;
}

.name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.name-row h3 {
  margin: 0;
  font-size: 1.35rem;
  font-family: "Iropke Batang", "Noto Serif KR", serif;
}

.badge {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  border-radius: 999px;
  padding: 6px 10px;
  background: rgba(185, 111, 62, 0.1);
  color: var(--brand-dark);
  font-size: 0.8rem;
  font-weight: 700;
}

.name-card p {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.65;
}

.name-card:hover,
.name-card:focus-visible {
  transform: translateY(-2px);
  border-color: rgba(185, 111, 62, 0.32);
  box-shadow: 0 16px 30px rgba(100, 68, 43, 0.1);
}

.name-card.is-selected {
  border-color: rgba(185, 111, 62, 0.56);
  box-shadow: 0 18px 34px rgba(185, 111, 62, 0.14);
}

.analysis-card,
.hanja-panel {
  margin-top: 14px;
  padding: 18px;
  border-radius: 22px;
  border: 1px solid rgba(123, 91, 63, 0.14);
  background: var(--panel-fill);
}

.analysis-card h3,
.hanja-head h3,
.hanja-preview h3 {
  margin: 0;
  font-family: "Iropke Batang", "Noto Serif KR", serif;
  font-size: 1.15rem;
}

.analysis-card p,
.hanja-head p,
.hanja-preview p,
.hanja-option p {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.65;
}

.element-meter {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.element-pill {
  padding: 10px 8px;
  border-radius: 18px;
  background: var(--panel-soft);
  border: 1px solid rgba(185, 111, 62, 0.12);
  text-align: center;
}

.element-pill strong {
  display: block;
  font-size: 0.92rem;
}

.element-pill span {
  display: block;
  margin-top: 4px;
  font-size: 0.8rem;
  color: var(--muted);
}

.hanja-panel {
  display: grid;
  gap: 16px;
}

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

.hanja-column {
  padding: 14px;
  border-radius: 18px;
  background: var(--panel-soft);
  border: 1px solid rgba(123, 91, 63, 0.12);
}

.hanja-column h4 {
  margin: 0 0 10px;
  font-size: 0.96rem;
}

.hanja-options {
  display: grid;
  gap: 8px;
}

.hanja-option {
  width: 100%;
  min-height: 92px;
  padding: 10px 12px;
  text-align: left;
  border-radius: 16px;
  border: 1px solid rgba(123, 91, 63, 0.12);
  background: var(--control-fill);
  cursor: pointer;
  transition: border-color 0.25s ease, transform 0.25s ease;
}

.hanja-option strong {
  display: block;
  font-size: 1rem;
}

.hanja-option small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.hanja-option p {
  margin-top: 6px;
  font-size: 0.86rem;
}

.hanja-option:hover,
.hanja-option:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(185, 111, 62, 0.3);
}

.hanja-option.is-active {
  border-color: rgba(185, 111, 62, 0.55);
  background: var(--toggle-fill);
}

.hanja-preview {
  padding: 16px;
  border-radius: 18px;
  background: var(--summary-surface);
  border: 1px solid rgba(123, 91, 63, 0.12);
}

.hanja-preview-name {
  margin-top: 10px;
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  font-family: "Iropke Batang", "Noto Serif KR", serif;
}

.hanja-detail-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.hanja-detail {
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--control-fill);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes card-in {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 900px) {
  .page-shell {
    width: min(100% - 24px, 100%);
    padding: 28px 0 44px;
  }

  .hero {
    padding: 24px;
  }

  .hero h1 {
    font-size: clamp(1.85rem, 7vw, 3.1rem);
  }

  .layout {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .hanja-grid,
  .element-meter {
    grid-template-columns: 1fr;
  }

  .contact-panel {
    margin-top: 16px;
  }
}

@media (max-width: 640px) {
  .page-shell {
    width: min(100% - 16px, 100%);
    padding: 16px 0 32px;
  }

  .hero,
  .panel {
    padding: 18px;
    border-radius: 22px;
  }

  .hero {
    padding-top: 16px;
  }

  .eyebrow,
  .section-kicker {
    margin-bottom: 8px;
    letter-spacing: 0.14em;
  }

  .hero h1 {
    font-size: clamp(1.7rem, 8vw, 2.4rem);
    line-height: 1.18;
  }

  .hero-copy,
  .contact-copy,
  .summary-card p,
  .analysis-card p,
  .hanja-head p,
  .hanja-preview p,
  .name-card p {
    font-size: 0.95rem;
    line-height: 1.6;
  }

  .field-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .birth-grid {
    gap: 10px;
  }

  .birth-grid > label {
    min-width: 0;
    overflow: hidden;
  }

  .panel-head {
    margin-bottom: 14px;
  }

  .panel-head h2 {
    font-size: 1.35rem;
  }

  .naming-form,
  .contact-form {
    gap: 12px;
  }

  label {
    gap: 6px;
    font-size: 0.92rem;
  }

  input,
  select,
  textarea {
    padding: 13px 14px;
    border-radius: 16px;
  }

  #birthDate,
  #birthTime {
    min-height: 54px;
    font-size: 16px;
    padding-right: 10px;
  }

  .primary-button {
    min-height: 52px;
    padding: 14px 16px;
    border-radius: 16px;
  }

  .hero-topbar {
    align-items: center;
    flex-direction: row;
    gap: 12px;
  }

  .theme-toggle {
    margin-left: auto;
    width: 48px;
    min-height: 48px;
  }

  .summary-card,
  .analysis-card,
  .hanja-panel,
  .name-card,
  .hanja-column,
  .hanja-preview {
    padding: 16px;
    border-radius: 18px;
  }

  .name-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .name-row h3 {
    font-size: 1.18rem;
  }

  .badge {
    padding: 5px 9px;
    font-size: 0.76rem;
  }

  .element-pill {
    padding: 12px 10px;
  }

  .hanja-panel {
    gap: 12px;
  }

  .hanja-option {
    min-height: 84px;
    padding: 11px 12px;
  }

  .hanja-option strong {
    font-size: 0.96rem;
  }

  .hanja-option p {
    font-size: 0.82rem;
    line-height: 1.5;
  }

  .hanja-preview-name {
    font-size: clamp(1.35rem, 7vw, 1.8rem);
    word-break: keep-all;
  }
}

@media (max-width: 420px) {
  .page-shell {
    width: min(100% - 12px, 100%);
    padding-bottom: 24px;
  }

  .hero,
  .panel {
    padding: 14px;
    border-radius: 18px;
  }

  .hero h1 {
    font-size: clamp(1.5rem, 9vw, 2rem);
  }

  .hero-topbar {
    gap: 10px;
  }

  .hero-copy,
  .contact-copy {
    margin-top: 14px;
    font-size: 0.9rem;
  }

  .birth-grid {
    gap: 8px;
  }

  .birth-grid label {
    gap: 5px;
    font-size: 0.88rem;
  }

  #birthDate,
  #birthTime {
    padding: 12px;
    border-radius: 14px;
    min-height: 52px;
    width: 100%;
    max-width: 100%;
    font-size: 16px;
    line-height: 1.1;
    letter-spacing: -0.01em;
  }

  #birthDate::-webkit-datetime-edit,
  #birthTime::-webkit-datetime-edit {
    display: flex;
    align-items: center;
    min-width: 0;
    padding: 0;
  }

  #birthDate::-webkit-date-and-time-value,
  #birthTime::-webkit-date-and-time-value {
    display: inline-block;
    max-width: 100%;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .theme-toggle,
  .primary-button {
    font-size: 0.95rem;
  }

  .summary-card,
  .analysis-card,
  .hanja-panel,
  .name-card,
  .hanja-column,
  .hanja-preview,
  .hanja-detail {
    padding: 14px;
    border-radius: 16px;
  }

  .name-row h3,
  .summary-card h3,
  .analysis-card h3,
  .hanja-head h3,
  .hanja-preview h3 {
    font-size: 1.02rem;
  }

  .hanja-column h4 {
    font-size: 0.9rem;
  }
}
