:root {
  --surface-0: #faf9f5;
  --surface-1: #f5f4ee;
  --surface-2: #ffffff;
  --text-primary: #1f1e1d;
  --text-secondary: #5e5d59;
  --text-muted: #8a8880;
  --text-warning: #854f0b;
  --text-danger: #a32d2d;
  --border: rgba(31, 30, 29, 0.12);
  --border-warning: #fac775;
  --fill-warning: #ba7517;
  --bg-warning: #faeeda;
  --bg-teal: #e1f5ee;
  --fill-teal: #1d9e75;
  --text-teal: #0f6e56;
  --font-voice: "Gowun Batang", "Batang", Georgia, serif;
  --font-sans: "Gowun Dodum", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  --radius: 8px;
}

[data-category="calc"] {
  --cat-bg: var(--bg-warning);
  --cat-fill: var(--fill-warning);
  --cat-text: var(--text-warning);
}

[data-category="text"] {
  --cat-bg: var(--bg-teal);
  --cat-fill: var(--fill-teal);
  --cat-text: var(--text-teal);
}

[data-category="guide"] {
  --cat-bg: var(--surface-1);
  --cat-fill: var(--text-muted);
  --cat-text: var(--text-primary);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --surface-0: #1f1e1d;
    --surface-1: #2b2a27;
    --surface-2: #262523;
    --text-primary: #f1efe8;
    --text-secondary: #b4b2a9;
    --text-muted: #87867f;
    --text-warning: #fac775;
    --text-danger: #f09595;
    --border: rgba(241, 239, 232, 0.14);
    --border-warning: #854f0b;
    --fill-warning: #ef9f27;
    --bg-warning: #412402;
    --bg-teal: #04342c;
    --fill-teal: #5dcaa5;
    --text-teal: #9fe1cb;
  }
}

:root[data-theme="dark"] {
  --surface-0: #1f1e1d;
  --surface-1: #2b2a27;
  --surface-2: #262523;
  --text-primary: #f1efe8;
  --text-secondary: #b4b2a9;
  --text-muted: #87867f;
  --text-warning: #fac775;
  --text-danger: #f09595;
  --border: rgba(241, 239, 232, 0.14);
  --border-warning: #854f0b;
  --fill-warning: #ef9f27;
  --bg-warning: #412402;
  --bg-teal: #04342c;
  --fill-teal: #5dcaa5;
  --text-teal: #9fe1cb;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--surface-0);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.7;
  -webkit-text-size-adjust: 100%;
}

a {
  color: var(--text-warning);
}

h1,
h2 {
  font-family: var(--font-voice);
  font-weight: 500;
  color: var(--text-primary);
  margin: 0 0 12px;
}

h1 {
  font-size: 30px;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 20px;
  margin-top: 40px;
}

p {
  margin: 0 0 12px;
  color: var(--text-secondary);
}

.site-header,
main,
.site-footer {
  max-width: 1080px;
  margin: 0 auto;
  padding-left: 16px;
  padding-right: 16px;
}

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 24px;
  padding-top: 16px;
  padding-bottom: 16px;
}

.site-nav {
  display: flex;
  gap: 20px;
  flex: 1;
}

.site-nav a {
  font-size: 14px;
  color: var(--text-secondary);
  text-decoration: none;
}

.site-nav a:hover {
  color: var(--text-primary);
}

.site-name {
  font-weight: 500;
  color: var(--text-primary);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.lang-switch {
  font-size: 14px;
  text-decoration: none;
}

.home .lead {
  font-size: 16px;
  margin-bottom: 32px;
}

.category {
  margin-top: 32px;
}

.category h2 {
  font-size: 15px;
  font-family: var(--font-sans);
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 0;
}

.category h2::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--cat-fill);
  vertical-align: middle;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.tool-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 18px;
  border-radius: 12px;
  background: var(--cat-bg);
  color: var(--text-primary);
  text-decoration: none;
}

.tool-card:hover {
  box-shadow: inset 0 0 0 1px var(--cat-fill);
}

.tool-card-title {
  font-weight: 500;
  color: var(--cat-text);
}

.tool-card-desc {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.tool .intro p {
  max-width: 680px;
}

.tool-form {
  display: grid;
  gap: 16px;
  margin-top: 24px;
  background: var(--surface-2);
  border-radius: 12px;
  padding: 24px;
}

.field label,
.field-check label {
  display: block;
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.field-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.field-row input {
  flex: 1;
  min-width: 0;
}

.unit {
  font-size: 14px;
  color: var(--text-muted);
}

input[type="text"],
input[type="date"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text-primary);
  font: inherit;
  font-size: 16px;
}

textarea {
  resize: vertical;
}

.field-check {
  display: flex;
  align-items: center;
  gap: 8px;
}

.field-check label {
  margin: 0;
}

.results {
  display: grid;
  gap: 16px;
  align-content: start;
  background: var(--cat-bg);
  border-radius: 12px;
  padding: 24px;
}

.output-label {
  display: block;
  font-size: 13px;
  color: var(--cat-text);
}

.output output {
  display: block;
  font-size: 16px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 1.7em;
}

.output-primary output {
  font-family: var(--font-voice);
  font-size: 36px;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.copy-btn {
  margin-top: 8px;
  padding: 6px 14px;
  border: 0.5px solid var(--cat-fill);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--cat-text);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

.copy-btn:hover {
  box-shadow: inset 0 0 0 1px var(--cat-fill);
}

.share {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  margin-top: 12px;
}

.share .copy-btn {
  margin-top: 0;
}

.share-hint {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

.error {
  margin: 0;
  color: var(--text-danger);
  font-size: 14px;
}

.howto ol {
  padding-left: 20px;
  color: var(--text-secondary);
}

.formula p,
.example p {
  max-width: 680px;
}

.notes ul,
.sources ul,
.privacy ul,
.about ul {
  max-width: 680px;
  padding-left: 20px;
  color: var(--text-secondary);
}

.privacy p,
.about p,
.guide p,
.guide-hub .lead {
  max-width: 680px;
}

.guide ul {
  max-width: 680px;
  padding-left: 20px;
  color: var(--text-secondary);
}

.guide li {
  margin-bottom: 8px;
}

.guide .intro p {
  font-size: 17px;
}

.cta {
  display: inline-block;
  padding: 12px 20px;
  border-radius: 12px;
  background: var(--cat-bg);
  color: var(--cat-text);
  font-weight: 500;
  text-decoration: none;
}

.cta:hover {
  box-shadow: inset 0 0 0 1px var(--cat-fill);
}

.related-guide p {
  margin: 0;
}

.schedule {
  margin-top: 16px;
  padding: 16px 20px;
  border-radius: 12px;
  background: var(--surface-2);
}

.schedule summary {
  cursor: pointer;
  font-weight: 500;
  color: var(--text-primary);
}

.table-wrap {
  margin-top: 12px;
  max-height: 420px;
  overflow: auto;
}

.schedule table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.schedule th,
.schedule td {
  padding: 6px 8px;
  text-align: right;
  white-space: nowrap;
  border-bottom: 0.5px solid var(--border);
}

.schedule th:first-child,
.schedule td:first-child {
  text-align: center;
}

.schedule thead th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  color: var(--text-secondary);
  font-weight: 500;
}

.notes li,
.sources li,
.privacy li {
  margin-bottom: 6px;
}

.updated {
  margin-top: 32px;
  font-size: 13px;
  color: var(--text-muted);
}

.faq details {
  border-top: 0.5px solid var(--border);
  padding: 12px 0;
}

.faq details:last-child {
  border-bottom: 0.5px solid var(--border);
}

.faq summary {
  cursor: pointer;
  color: var(--text-primary);
  font-weight: 500;
}

.faq details p {
  margin-top: 8px;
}

.site-footer {
  margin-top: 48px;
  padding-top: 24px;
  padding-bottom: 32px;
  border-top: 0.5px solid var(--border);
}

.site-footer p {
  font-size: 13px;
  color: var(--text-muted);
}

@media (min-width: 768px) {
  .tool-form {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    column-gap: 32px;
    padding: 32px;
  }

  .tool-form > .field,
  .tool-form > .field-check {
    grid-column: 1;
  }

  .tool-form > .results {
    grid-column: 2;
    grid-row: 1 / span 6;
    padding: 28px;
  }

  .tool-form > .error {
    grid-column: 1 / -1;
  }
}

@media (max-width: 767px) {
  h1 {
    font-size: 26px;
  }

  .site-nav {
    order: 3;
    flex-basis: 100%;
  }

  .tool-form {
    padding: 20px 16px;
  }

  .schedule {
    padding: 14px 10px;
  }

  .schedule table {
    font-size: 12px;
  }

  .schedule th,
  .schedule td {
    padding: 6px 4px;
  }
}
