:root {
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --border: #e2e8f0;
  --border-focus: #3b82f6;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --emerald: #059669;
  --emerald-light: #ecfdf5;
  --danger: #ef4444;
  --danger-light: #fef2f2;
  --radius: 16px;
  --radius-sm: 8px;
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.05), 0 2px 4px -2px rgb(0 0 0 / 0.05);
  --shadow-lg: 0 20px 25px -5px rgb(0 0 0 / 0.07), 0 8px 10px -6px rgb(0 0 0 / 0.05);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-container {
  max-width: 760px;
  margin: 48px auto;
  padding: 0 20px;
  width: 100%;
  flex: 1;
}

/* Header */
.header {
  text-align: center;
  margin-bottom: 32px;
}

.badge-live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--emerald-light);
  color: var(--emerald);
  border-radius: 9999px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 16px;
}

.dot-live {
  width: 8px;
  height: 8px;
  background-color: var(--emerald);
  border-radius: 50%;
  box-shadow: 0 0 0 2px #a7f3d0;
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.2); }
}

.title {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
  color: var(--text-main);
}

.subtitle {
  font-size: 16px;
  color: var(--text-muted);
}

/* Search Section */
.search-section {
  position: relative;
  margin-bottom: 16px;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--card-bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 16px;
  box-shadow: var(--shadow);
  transition: all 0.2s ease;
}

.search-box:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.search-icon {
  width: 22px;
  height: 22px;
  color: var(--text-light);
  margin-right: 12px;
  flex-shrink: 0;
}

.search-box input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 16px;
  font-weight: 500;
  background: transparent;
  color: var(--text-main);
}

.search-box input::placeholder {
  color: var(--text-light);
}

.clear-btn {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text-light);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}

.clear-btn:hover {
  color: var(--text-main);
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-left: 8px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Suggestions Dropdown */
.suggestions-list {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-height: 320px;
  overflow-y: auto;
  z-index: 50;
  list-style: none;
  padding: 6px;
}

.suggestion-item {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s ease;
}

.suggestion-item:hover,
.suggestion-item.active {
  background: var(--primary-light);
}

.sugg-road {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 2px;
}

.sugg-parcel {
  font-size: 13px;
  color: var(--text-muted);
}

/* Quick Tags */
.quick-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 24px;
  font-size: 13px;
}

.tag-label {
  color: var(--text-muted);
  font-weight: 500;
}

.tag-btn {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 9999px;
  padding: 4px 12px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.tag-btn:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

/* Error Card */
.error-card {
  background: var(--danger-light);
  border: 1px solid #fecaca;
  color: var(--danger);
  padding: 16px;
  border-radius: var(--radius);
  font-weight: 500;
  margin-bottom: 24px;
}

/* Result Card */
.result-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow-lg);
  margin-top: 16px;
  animation: fadeIn 0.3s ease-out;
}

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

.result-header {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.header-titles {
  display: flex;
  flex-direction: column;
}

.res-road {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 4px;
  letter-spacing: -0.01em;
}

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

/* Land Metadata Chips */
.land-meta-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
}

.chip-label {
  font-weight: 600;
  color: var(--text-light);
  font-size: 11px;
}

.chip-val {
  font-weight: 700;
  color: var(--text-main);
}

.chip-val.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  color: var(--text-muted);
}

/* Total Valuation Card (공시지가 기준 토지가액) */
.total-valuation-card {
  margin-top: 20px;
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
  border-radius: var(--radius);
  padding: 24px;
  color: #ffffff;
  box-shadow: 0 10px 15px -3px rgba(37, 99, 235, 0.2);
}

.valuation-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
  gap: 8px;
}

.valuation-tag {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #93c5fd;
  background: rgba(255, 255, 255, 0.15);
  padding: 3px 8px;
  border-radius: 4px;
}

.valuation-formula {
  font-size: 12px;
  color: #bfdbfe;
  font-weight: 500;
}

.valuation-main {
  font-size: 32px;
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 4px;
  color: #ffffff;
}

.valuation-raw {
  font-size: 13px;
  color: #bfdbfe;
  font-weight: 600;
  margin-bottom: 14px;
}

.valuation-disclaimer {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.75);
  line-height: 1.4;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  padding-top: 10px;
}

/* Metrics Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 20px 0;
}

.metric-box {
  padding: 18px 20px;
  border-radius: var(--radius);
  background: var(--bg);
  border: 1px solid var(--border);
}

.metric-box.primary {
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
  border-color: #bfdbfe;
}

.metric-box.secondary {
  background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
  border-color: #a7f3d0;
}

.metric-tag-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.metric-tag {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
}

.metric-box.primary .metric-tag {
  color: var(--primary);
}

.metric-box.secondary .metric-tag {
  color: var(--emerald);
}

/* YoY Change Badge */
.yoy-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 9999px;
  line-height: 1.3;
}

.yoy-badge.pos, .change-pos {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
}

.yoy-badge.neg, .change-neg {
  background: #eff6ff;
  color: #2563eb;
  border: 1px solid #bfdbfe;
}

.yoy-badge.zero, .change-zero {
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #e2e8f0;
}

.metric-main {
  font-size: 26px;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.2;
  margin-bottom: 4px;
}

.metric-sub {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

/* Calculator Box */
.calculator-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
}

.calc-header {
  margin-bottom: 14px;
}

.calc-header h3 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 2px;
}

.calc-desc {
  font-size: 12px;
  color: var(--text-muted);
}

.calc-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.input-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.input-group input {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  background: #fff;
  outline: none;
}

.input-group input:focus {
  border-color: var(--primary);
}

.calc-result {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}

.calc-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.calc-value {
  font-size: 18px;
  font-weight: 800;
  color: var(--primary);
}

.calc-raw {
  font-size: 12px;
  color: var(--text-light);
}

/* History Table */
.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.history-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 0;
}

.history-count {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
  background: #fff;
}

.history-table th {
  padding: 10px 12px;
  background: var(--bg);
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.history-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-main);
  white-space: nowrap;
}

.history-table tr:last-child td {
  border-bottom: none;
}

.history-table tr:hover td {
  background: #fafafa;
}

.history-footer {
  text-align: center;
  margin-top: 12px;
}

.toggle-history-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 44px;
}

.toggle-history-btn:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

/* AdSense Layout Slots */
.ad-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8fafc;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  margin: 24px 0;
  min-height: 100px;
  position: relative;
  overflow: hidden;
}

.ad-placeholder-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-light);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.ad-slot-middle {
  min-height: 120px;
}

.ad-slot-bottom {
  min-height: 120px;
}

/* Educational Content Layer */
.info-guide-section {
  margin-top: 36px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.guide-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

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

.guide-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 12px;
  letter-spacing: -0.01em;
}

.guide-subtitle {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 8px;
}

.guide-text {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-muted);
}

.guide-subtext {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 8px;
}

.code-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin: 10px 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
}

.comparison-table th {
  background: #f1f5f9;
}

/* FAQ Accordion Section */
.faq-section {
  margin-top: 36px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.faq-main-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}

.faq-item {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color 0.2s ease;
}

.faq-item[open] {
  border-color: var(--border-focus);
}

.faq-question {
  padding: 16px 20px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.faq-question::-webkit-details-marker {
  display: none;
}

.faq-question::after {
  content: "+";
  font-size: 18px;
  font-weight: 400;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

.faq-item[open] .faq-question::after {
  content: "−";
  color: var(--primary);
}

.faq-answer {
  padding: 0 20px 18px 20px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-muted);
  border-top: 1px dashed var(--border);
  padding-top: 14px;
}

/* Legal Pages Styling (/privacy, /terms) */
.legal-container {
  max-width: 800px;
}

.back-link {
  display: inline-block;
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
}

.back-link:hover {
  text-decoration: underline;
}

.legal-content {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.legal-section h2 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 10px;
}

.legal-section p, .legal-section li {
  font-size: 14px;
  line-height: 1.8;
  color: var(--text-muted);
}

.legal-section ul {
  padding-left: 20px;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.legal-section a {
  color: var(--primary);
  text-decoration: underline;
}

.legal-date {
  margin-top: 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-light);
}

/* Footer & Disclaimers */
.footer {
  text-align: center;
  padding: 36px 20px;
  font-size: 12px;
  color: var(--text-muted);
  background: #f1f5f9;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.footer-links {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.footer-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 600;
}

.footer-links a:hover {
  color: var(--primary);
  text-decoration: underline;
}

.footer-divider {
  color: var(--border);
}

.footer-disclaimer {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  line-height: 1.6;
}

.disclaimer-title {
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 2px;
}

.footer-copy {
  margin-top: 12px;
  font-size: 11px;
  color: var(--text-light);
}

@media (max-width: 600px) {
  .app-container {
    margin: 16px auto;
    padding: 0 14px;
  }
  .title {
    font-size: 24px;
  }
  .valuation-main {
    font-size: 26px;
  }
  .metrics-grid {
    grid-template-columns: 1fr;
  }
  .calc-inputs {
    grid-template-columns: 1fr;
  }
  .guide-grid {
    grid-template-columns: 1fr;
  }
  .legal-content {
    padding: 20px;
  }
}

/* v1 practitioner workflow and keyboard/touch accessibility */
[hidden] { display: none !important; }
.clear-btn { min-width: 44px; min-height: 44px; }
.tag-btn { min-height: 44px; }
.action-btn {
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card-bg);
  color: var(--text-main);
  font: inherit;
  cursor: pointer;
}
.result-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.search-status, .data-provenance, .parcel-notice { font-size: 13px; color: var(--text-muted); margin: 10px 0; }
.data-provenance a { color: var(--primary); text-underline-offset: 3px; }
.result-notice { padding: 14px; margin: 14px 0; border: 1px solid #d97706; border-radius: 8px; background: #fffbeb; color: #78350f; }
.copy-fallback { width: 100%; min-height: 160px; padding: 12px; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 3px solid var(--primary); outline-offset: 3px;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
