* {
  box-sizing: border-box;
}

:root {
  --paper: #f6efdf;
  --paper-deep: #ede1c7;
  --paper-line: #aa9675;
  --paper-line-soft: rgba(170, 150, 117, 0.45);
  --text-main: #2a1d13;
  --text-soft: #6f6255;
  --text-muted: #857666;
  --input-border: #c7c0b6;
  --primary: #24356f;
  --primary-shadow: rgba(36, 53, 111, 0.28);
  --button-border: rgba(85, 66, 40, 0.18);
  --result-border: rgba(111, 101, 89, 0.72);
  --result-board-width: 810px;
  --result-panel-border-width: 2px;
  --result-panel-edge-gap: 0.1mm;
  --result-surface: #f7f1e6;
  --result-surface-image:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.9), transparent 35%),
    linear-gradient(180deg, #f7f1e6 0%, #f4ead4 48%, #f7eedf 100%);
  --success: #2b6d4b;
  --error: #b13d2d;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text-main);
  font-family: Georgia, "Times New Roman", serif;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.9), transparent 35%),
    linear-gradient(180deg, #f7f1e6 0%, #f4ead4 48%, #f7eedf 100%);
}

.page-shell {
  width: min(1380px, calc(100% - 40px));
  margin: 16px auto 28px;
}

.page-hero {
  text-align: center;
}

.page-hero h1 {
  margin: 0;
  font-family: "Arial Narrow", Arial, sans-serif;
  font-size: clamp(1.5rem, 3vw, 2.1rem);
  font-weight: 700;
  line-height: 1.04;
  letter-spacing: -0.02em;
}

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

.entry-panel {
  width: min(690px, 100%);
  margin-left: auto;
  margin-right: auto;
}

.form-frame {
  position: relative;
  padding: 14px 14px 14px;
  border: 2px solid var(--paper-line);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.66), rgba(255, 255, 255, 0.5)),
    linear-gradient(180deg, rgba(250, 244, 230, 0.88), rgba(247, 239, 223, 0.96));
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.65),
    0 10px 24px rgba(143, 121, 78, 0.08);
}

.form-frame::before {
  content: "";
  position: absolute;
  inset: 7px;
  border: 1px solid var(--paper-line-soft);
  border-radius: 12px;
  pointer-events: none;
}

.panel-grid,
.action-cluster,
.status-message {
  position: relative;
  z-index: 1;
}

.identity-row {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(180px, 0.85fr);
  gap: 10px;
  align-items: end;
}

.text-input,
input[type="number"],
select {
  width: 100%;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--input-border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--text-main);
  font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
  font-size: 0.88rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.text-input::placeholder {
  color: #897b6e;
}

.text-input:focus,
input[type="number"]:focus,
select:focus {
  outline: none;
  border-color: #9d8258;
  box-shadow: 0 0 0 3px rgba(157, 130, 88, 0.14);
}

.panel-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.panel-box {
  min-width: 0;
  margin: 0;
  padding: 11px 10px 10px;
  border: 2px solid var(--paper-line);
  border-radius: 12px;
  background: rgba(255, 251, 244, 0.42);
}

.panel-box legend {
  padding: 0 6px;
  color: #705c3d;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.94rem;
}

.option-group + .option-group {
  margin-top: 8px;
}

.option-group-inline {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 0;
}

.option-group-inline .group-label {
  flex: 0 0 auto;
  min-width: 56px;
  margin: 0;
}

.option-group-inline .choice-row {
  flex: 1 1 0;
}

.calendar-mode-group {
  align-items: center;
}

.calendar-mode-group .choice-row {
  flex: 1 1 auto;
  flex-wrap: nowrap;
  gap: 8px;
  min-width: 11.2rem;
}

.calendar-mode-group .choice-inline {
  white-space: nowrap;
}

.group-label {
  display: block;
  margin: 0 0 6px;
  font-family: "Arial Narrow", Arial, sans-serif;
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.choice-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
}

.choice-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
  font-size: 0.86rem;
}

input[type="radio"] {
  width: 17px;
  height: 17px;
  accent-color: #5c78df;
}

input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: #5c78df;
}

.field-note,
.meta-copy,
.result-summary,
.status-message {
  color: var(--text-soft);
  font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
}

.field-note {
  margin: 7px 0 0;
  font-size: 0.78rem;
  line-height: 1.35;
}

.birth-date-hint {
  margin: 0;
}

.birth-grid,
.time-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
  margin-top: 10px;
}

.birth-meta-row {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.stack-field {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
  font-size: 0.84rem;
}

.stack-field > span {
  flex: 0 0 auto;
  min-width: 56px;
  font-weight: 700;
  white-space: nowrap;
}

.name-field > span {
  font-size: calc(0.84rem + 2px);
}

.stack-field > .text-input,
.stack-field > input[type="number"],
.stack-field > select {
  width: auto;
  min-width: 0;
  flex: 1 1 0;
}

.choice-inline-accent {
  padding: 6px 10px;
  border: 1px solid rgba(170, 150, 117, 0.36);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.55);
}

.is-hidden {
  display: none !important;
}

.action-cluster {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 7px;
  margin-top: 12px;
}

.action-button {
  width: auto;
  min-width: 116px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--button-border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  color: #4a3b29;
  font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
  font-size: 0.84rem;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(116, 95, 58, 0.08);
}

.action-button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.action-button:disabled {
  opacity: 0.72;
  cursor: wait;
}

.action-button-primary {
  border-color: rgba(18, 29, 70, 0.28);
  background: linear-gradient(180deg, #2e4388 0%, #22356f 100%);
  color: #fff;
  box-shadow: 0 10px 22px var(--primary-shadow);
}

.status-message {
  min-height: 1.6rem;
  margin: 9px 0 0;
  text-align: center;
  font-size: 0.78rem;
}

.status-message-hidden {
  display: none;
}

.status-message-success {
  color: var(--success);
}

.status-message-error {
  color: var(--error);
}

.result-heading {
  margin: 0 0 0.3mm;
  text-align: center;
  font-family: "Arial Narrow", Arial, sans-serif;
  font-size: clamp(1.176rem, 2.254vw, 1.568rem);
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: 0.01em;
  color: var(--text-main);
}

.result-heading-prefix {
  color: inherit;
}

.result-heading-name {
  color: #ff3131;
}

.result-heading-hidden {
  display: none;
}

.result-panel {
  width: min(
    100%,
    calc(
      var(--result-board-width) +
      (var(--result-panel-border-width) * 2) +
      (var(--result-panel-edge-gap) * 2)
    )
  );
  margin: 2cm auto 0;
  padding: 3mm var(--result-panel-edge-gap) var(--result-panel-edge-gap);
  border: var(--result-panel-border-width) solid var(--result-border);
  border-radius: 8px;
  background-color: var(--result-surface);
  background-image: var(--result-surface-image);
  box-shadow: 0 12px 28px rgba(116, 95, 58, 0.1);
}

.result-panel-hidden {
  display: none;
}

.result-viewport {
  width: 100%;
  min-height: 0;
  overflow: hidden;
  background-color: var(--result-surface);
  background-image: var(--result-surface-image);
  touch-action: pan-x pan-y pinch-zoom;
}

#result-frame {
  display: block;
  width: 100%;
  height: 0;
  min-height: 0;
  margin-top: 0;
  border: 0;
  border-radius: 0;
  background-color: var(--result-surface);
  background-image: var(--result-surface-image);
  overflow: hidden;
  transform-origin: top left;
}

#result-frame.result-frame-hidden {
  display: none;
}

@media (max-width: 1100px) {
  .page-shell {
    width: min(100%, calc(100% - 24px));
  }

  .entry-panel {
    width: min(100%, 690px);
  }

  .panel-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .page-shell {
    margin-top: 12px;
    margin-bottom: 22px;
  }

  .page-hero h1 {
    font-size: clamp(1.3rem, 6vw, 1.7rem);
  }

  .form-frame {
    padding: 14px 12px 16px;
  }

  .form-frame::before {
    inset: 6px;
  }

  .birth-grid,
  .time-grid,
  .action-cluster {
    grid-template-columns: 1fr;
  }

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

  .action-button {
    width: 100%;
  }

  .result-panel {
    margin-top: 28px;
  }

  .result-heading {
    margin-bottom: 0.3mm;
  }

  #result-frame {
    min-height: 1118px;
  }
}
