/* Input and feedback components (md-): checkbox, text input, field, select, segmented control, chips,
   callout, tabs. Same as the design system's 입력·피드백 components; every value comes from tokens.css. */
:root {
  --md-icon-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  --md-icon-dash: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 12h12' stroke='black' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E");
  --md-icon-x: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 7l10 10M17 7L7 17' stroke='black' stroke-width='2.6' stroke-linecap='round'/%3E%3C/svg%3E");
  --md-icon-down: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 9l6 6 6-6' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* Checkbox: the whole label is the tap target */
.md-check {
  position: relative; display: inline-flex; align-items: flex-start; gap: var(--space-2);
  min-height: 32px; padding: var(--space-1) 0; font-size: var(--text-body); line-height: 24px;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.md-check.lg { min-height: 36px; font-size: var(--text-title-3); line-height: 28px; }
.md-check.bold { font-weight: var(--weight-bold); }
.md-check input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; }
.md-check-mark {
  flex: none; position: relative; display: grid; place-content: center;
  width: var(--check-md); height: var(--check-md); margin-top: 2px;
  border: 1.5px solid var(--color-control-border); background: var(--color-page);
  transition: background-color var(--duration), border-color var(--duration), transform var(--duration);
}
.md-check.lg .md-check-mark { width: var(--check-lg); height: var(--check-lg); }
.md-check-mark { border-radius: var(--radius-xs); }
.md-check-mark::after {
  content: ""; width: 12px; height: 12px; background: var(--color-on-dark); opacity: 0;
  -webkit-mask: var(--md-icon-check) center / contain no-repeat; mask: var(--md-icon-check) center / contain no-repeat;
}
.md-check.lg .md-check-mark::after { width: 15px; height: 15px; }
.md-check input:checked + .md-check-mark, .md-check input:indeterminate + .md-check-mark { border-color: transparent; background: var(--color-brand); }
.md-check input:checked + .md-check-mark::after, .md-check input:indeterminate + .md-check-mark::after { opacity: 1; }
.md-check input:indeterminate + .md-check-mark::after { -webkit-mask-image: var(--md-icon-dash); mask-image: var(--md-icon-dash); }
.md-check.neutral input:checked + .md-check-mark, .md-check.neutral input:indeterminate + .md-check-mark { background: var(--color-button); }
/* Ghost: only the check, no box */
.md-check.plain .md-check-mark { border-color: transparent; background: none; border-radius: 50%; }
.md-check.plain .md-check-mark::after { width: 18px; height: 18px; opacity: 1; background: var(--color-control-border); }
.md-check.plain.lg .md-check-mark::after { width: 22px; height: 22px; }
.md-check.plain input:checked + .md-check-mark { background: none; }
.md-check.plain input:checked + .md-check-mark::after { background: var(--color-brand); }
.md-check.plain.neutral input:checked + .md-check-mark::after { background: var(--color-ink); }
.md-check:active .md-check-mark { transform: scale(.9); }
.md-check.plain:active .md-check-mark { background: var(--color-pressed); }
.md-check input:focus-visible + .md-check-mark { outline: 2px solid var(--color-brand); outline-offset: 2px; }
.md-check:has(input:disabled) { color: var(--color-text-disabled); cursor: not-allowed; }
.md-check input:disabled + .md-check-mark { border-color: var(--gray-300); background: var(--color-disabled-bg); transform: none; }
.md-check input:disabled + .md-check-mark::after { background: var(--color-disabled-ink); }
.md-check.plain input:disabled + .md-check-mark { border-color: transparent; background: none; }
.md-group { display: grid; gap: var(--space-1); margin: 0; padding: 0; border: 0; }
.md-group .md-group { padding-left: calc(var(--check-md) + var(--space-2)); }

/* Text area: same box as .md-input for several lines (의견 보내기 내용). Grows with the text up to 2× its height */
.md-textarea { display: block; padding: 14px; border: 1px solid var(--color-line); border-radius: var(--radius-md); background: var(--color-soft); transition: border-color var(--duration), box-shadow var(--duration); }
.md-textarea textarea { display: block; width: 100%; min-height: 160px; padding: 0; border: 0; outline: none; background: none; resize: vertical; font: inherit; font-size: var(--text-body); line-height: 1.6; color: var(--color-text-primary); field-sizing: content; max-height: 320px; }
.md-textarea textarea::placeholder { color: var(--color-text-placeholder); }
.md-textarea:focus-within { border-color: var(--color-brand); box-shadow: 0 0 0 1px var(--color-brand); }

/* Text input: a box (or an underline) around one line of text, with optional prefix, suffix and clear button */
.md-input {
  display: flex; align-items: center; gap: var(--space-2); min-height: var(--control-height); padding: 0 14px;
  border: 1px solid var(--color-line); border-radius: var(--radius-md); background: var(--color-soft);
  transition: border-color var(--duration), box-shadow var(--duration);
}
.md-input input { flex: 1; min-width: 0; height: calc(var(--control-height) - 2px); padding: 0; border: 0; outline: none; background: none; font: inherit; font-size: var(--text-body); color: var(--color-text-primary); }
.md-input input::placeholder { color: var(--color-text-placeholder); }
.md-input:focus-within { border-color: var(--color-brand); box-shadow: 0 0 0 1px var(--color-brand); }
.md-input.is-error { border-color: var(--color-error); }
.md-input.is-error:focus-within { box-shadow: 0 0 0 1px var(--color-error); }
.md-input.is-disabled { border-color: var(--gray-200); background: var(--color-disabled-bg); }
.md-input.is-disabled input { color: var(--color-text-disabled); -webkit-text-fill-color: var(--color-disabled-ink); }
.md-input.is-readonly { border-style: dashed; background: var(--color-page); }
.md-input.is-readonly:focus-within { border-color: var(--color-line); box-shadow: none; }
.md-input-affix { flex: none; color: var(--color-text-tertiary); white-space: nowrap; }
/* Chips inside an input, on the right (생년월일: 양력 / 음력). Radios underneath; the picked one is the dark button colour. */
.md-input-chips { flex: none; display: flex; gap: var(--space-1); }
.md-input-chips label { position: relative; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.md-input .md-input-chips input { position: absolute; width: 1px; height: 1px; margin: 0; padding: 0; opacity: 0; flex: none; }
.md-input-chips span {
  display: grid; place-items: center; height: 32px; padding: 0 var(--space-3); border-radius: var(--radius-pill);
  background: var(--gray-100); color: var(--color-text-secondary); font-size: var(--text-caption); font-weight: var(--weight-bold);
  transition: background-color var(--duration), color var(--duration);
}
.md-input-chips input:checked + span { background: var(--color-button); color: var(--color-text-inverse); }
.md-input-chips input:focus-visible + span { outline: 2px solid var(--color-brand); outline-offset: 2px; }
.md-input-clear {
  flex: none; display: grid; place-content: center; width: 24px; height: 24px; padding: 0; border: 0; border-radius: 50%;
  background: var(--gray-400); cursor: pointer;
}
.md-input-clear::before { content: ""; width: 12px; height: 12px; background: var(--color-on-dark); -webkit-mask: var(--md-icon-x) center / contain no-repeat; mask: var(--md-icon-x) center / contain no-repeat; }
.md-input:has(input:placeholder-shown) .md-input-clear, .md-input.is-disabled .md-input-clear, .md-input.is-readonly .md-input-clear { display: none; }
.md-input.underline { padding: 0; border-width: 0 0 1px; border-color: var(--color-control-border); border-radius: 0; background: none; }
.md-input.underline:focus-within { box-shadow: 0 1px 0 0 var(--color-brand); }
.md-input.underline input { font-size: var(--text-title-3); font-weight: var(--weight-medium); }

/* Field: label, description, control, then error or counter */
.md-field { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-2); margin: 0; padding: 0; border: 0; min-width: 0; }
.md-field-label { font-size: var(--text-body-sm); font-weight: var(--weight-bold); }
/* A fieldset's legend sits outside the grid, so it gets the same 8px gap as a margin */
legend.md-field-label { padding: 0; margin-bottom: var(--space-2); }
.md-field-label .req { margin-left: 2px; color: var(--color-text-accent); }
.md-field-label .opt { margin-left: var(--space-1); font-weight: var(--weight-regular); color: var(--color-text-tertiary); }
.md-field-desc { margin: 0; font-size: var(--text-caption); color: var(--color-text-tertiary); }
.md-field-foot { display: flex; gap: var(--space-2); font-size: var(--text-footnote); line-height: 1.5; color: var(--color-text-tertiary); }
.md-field-error { margin: 0; color: var(--color-text-error); font-weight: var(--weight-medium); }
.md-field-count { margin-left: auto; font-variant-numeric: tabular-nums; }

/* Select: the native picker, styled like an input */
.md-select { position: relative; display: block; }
.md-select select {
  -webkit-appearance: none; appearance: none; width: 100%; min-height: var(--control-height); padding: 0 44px 0 14px;
  border: 1px solid var(--color-line); border-radius: var(--radius-md); background: var(--color-soft);
  font: inherit; font-size: var(--text-body); color: var(--color-text-primary); cursor: pointer;
}
.md-select::after {
  content: ""; position: absolute; top: 50%; right: 14px; width: 20px; height: 20px; margin-top: -10px; pointer-events: none;
  background: var(--color-muted); -webkit-mask: var(--md-icon-down) center / contain no-repeat; mask: var(--md-icon-down) center / contain no-repeat;
}
.md-select.is-disabled select, .md-select select:disabled { background: var(--color-disabled-bg); color: var(--color-text-disabled); cursor: not-allowed; }
.md-select.is-disabled::after { background: var(--color-text-disabled); }
.md-select select:focus-visible { outline: none; border-color: var(--color-brand); box-shadow: 0 0 0 1px var(--color-brand); }
.md-select select:disabled { border-color: var(--gray-200); background: var(--color-disabled-bg); color: var(--color-text-disabled); cursor: not-allowed; }

/* Segmented control: two to four short choices in one track */
.md-segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; padding: 3px; margin: 0; border: 0; border-radius: var(--radius-md); background: var(--color-track); }
.md-segmented label { position: relative; }
.md-segmented input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; }
.md-segmented span {
  display: grid; place-content: center; min-height: 40px; padding: 0 var(--space-3); border-radius: 9px;
  font-size: var(--text-body-sm); font-weight: var(--weight-medium); color: var(--color-text-tertiary); cursor: pointer;
  transition: background-color var(--duration), color var(--duration);
}
.md-segmented input:checked + span { background: var(--color-page); color: var(--color-text-active); box-shadow: var(--shadow-knob); }
.md-segmented input:focus-visible + span { outline: 2px solid var(--color-brand); outline-offset: -2px; }

/* Callout: an inline notice inside the page */
/* Choice chips: pick one of a few short words (관계). Every selectable chip looks the same: unpicked is a
   borderless gray-100 pill with secondary text, picked is the dark button colour (as .md-input-chips). Radios underneath. */
.md-chips { display: flex; gap: 6px; }  /* one row: the chips share the width (fits 6 short words down to 320px) */
.md-chips label { position: relative; flex: 1 0 auto; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.md-chips input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; }
.md-chips span {
  display: grid; place-items: center; min-height: 44px; padding: 0 6px;
  border: 0; border-radius: var(--radius-pill); background: var(--gray-100);
  font-size: var(--text-body); font-weight: var(--weight-bold); color: var(--color-text-secondary);
  transition: background-color var(--duration), color var(--duration);
}
.md-chips input:checked + span { background: var(--color-button); color: var(--color-text-inverse); }
.md-chips label.is-disabled { cursor: not-allowed; }
.md-chips input:disabled + span { opacity: .4; }  /* 못 고르는 칩(예: 이미 나가 있을 때 "나") */
.md-chips input:focus-visible + span { outline: 2px solid var(--color-brand); outline-offset: 2px; }
.md-chips label:active span { transform: scale(.97); }

/* Pick chips: a row of small buttons that pick one thing (e.g. 궁합 볼 사람). 36px pills that wrap to more lines,
   same colours as .md-chips: unpicked gray-100 + secondary bold, picked (aria-pressed="true") the dark button colour. */
.md-pick { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: 0; padding: 0; list-style: none; }
.md-pick button {
  min-height: 36px; padding: 0 var(--space-4); border: 0; border-radius: var(--radius-pill); background: var(--gray-100);
  font: inherit; font-size: var(--text-caption); font-weight: var(--weight-bold); line-height: 1; color: var(--color-text-secondary); cursor: pointer;
  -webkit-tap-highlight-color: transparent; transition: background-color var(--duration), color var(--duration);
}
.md-pick button[aria-pressed="true"] { background: var(--color-button); color: var(--color-text-inverse); }
.md-pick button:focus-visible { outline: 2px solid var(--color-brand); outline-offset: 2px; }
.md-pick button:active { transform: scale(.97); }
.md-pick button small { margin-left: 2px; font-size: var(--text-caption); font-weight: var(--weight-medium); opacity: .7; }  /* 칩 옆 개수 */
/* 한 줄로 옆으로 넘기는 필터 칩(.md-pick.scroll): 리포트·사주 보관함. 줄바꿈 없이 화면 끝까지 닿고(양옆 여백만큼 바깥으로),
   처음과 끝 칩은 여백에 맞춰 시작·끝남. 칩이 늘어나도 모양 그대로 */
.md-pick.scroll {
  flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; overscroll-behavior-x: contain;
  margin: var(--space-2) calc(var(--gutter) * -1) var(--space-4); padding: 0 var(--gutter);
}
.md-pick.scroll::-webkit-scrollbar { display: none; }
.md-pick.scroll li { flex: none; }
.md-pick.scroll button { white-space: nowrap; }

.md-callout { display: flex; align-items: flex-start; gap: var(--space-3); padding: 14px var(--space-4); border-radius: var(--radius-md); background: var(--color-soft); font-size: var(--text-body-sm); line-height: 1.6; }
.md-callout.tint { background: var(--color-brand-tint); color: var(--color-text-brand); }
.md-callout-face { flex: none; width: 32px; height: 32px; border-radius: 50%; object-fit: cover; background: var(--char-background); }
.md-callout-body { flex: 1; min-width: 0; }
.md-callout-title { display: block; margin-bottom: 2px; font-weight: var(--weight-bold); }
.md-callout-body p { margin: 0; }
.md-callout-close { flex: none; display: grid; place-content: center; width: 24px; height: 24px; margin: -1px -4px 0 0; padding: 0; border: 0; background: none; cursor: pointer; }
.md-callout-close img { width: 18px; height: 18px; }

/* Tabs: switch between views of one result */
.md-tabs { display: flex; margin: 0; padding: 0; border-bottom: 1px solid var(--color-divider); }
.md-tabs.scroll { overflow-x: auto; scrollbar-width: none; }
.md-tab {
  flex: 1; position: relative; min-height: 48px; padding: 0 var(--space-4); border: 0; background: none;
  font: inherit; font-size: var(--text-body); font-weight: var(--weight-medium); color: var(--color-text-tertiary); white-space: nowrap; cursor: pointer;
}
.md-tabs.scroll .md-tab { flex: none; }
.md-tab[aria-selected="true"] { color: var(--color-text-primary); font-weight: var(--weight-bold); }
.md-tab[aria-selected="true"]::after { content: ""; position: absolute; left: var(--space-2); right: var(--space-2); bottom: -1px; height: 2px; border-radius: 1px; background: var(--color-ink); }
.md-tab:active { background: var(--color-pressed); }
.md-tab:focus-visible { outline: 2px solid var(--color-brand); outline-offset: -2px; }

@media (prefers-reduced-motion: reduce) {
  .md-check-mark, .md-segmented span { transition: none; }
}
