/* ── Reset & Variables ─────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --brand: #1D4ED8;
  --brand-dark: #1E3A8A;
  --brand-light: #EFF6FF;
  --bg: #F0F4FF;
  --surface: #FFFFFF;
  --surface2: #F5F8FF;
  --border: #E0E7FF;
  --text: #1A1A2E;
  --text-muted: #888;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 4px 20px rgba(29,78,216,.10);
  --shadow-sm: 0 2px 8px rgba(0,0,0,.06);
  font-family: "Noto Sans KR", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body { background: var(--bg); color: var(--text); min-height: 100dvh; overflow-x: hidden; font-size: 16px; line-height: 1.6; word-break: keep-all; }
main { min-width: 0; overflow: hidden; }
button { cursor: pointer; border: none; font-family: inherit; }
a { text-decoration: none; color: inherit; }

/* ── Layout ────────────────────────────────────────────── */
.layout-container {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 24px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px 48px;
}
@media (max-width: 800px) {
  .layout-container { grid-template-columns: 1fr; }
  .app-sidebar { display: none; }
}

/* ── Ad containers ─────────────────────────────────────── */
.ad-container { display: block; width: 100%; margin: 0; text-align: center; }
.top-ad { background: #f9f9f9; padding: 8px 0; border-bottom: 1px solid var(--border); }
.middle-ad { margin: 20px 0; }
.bottom-ad { margin-top: 24px; padding: 16px 0; border-top: 1px solid var(--border); }

/* ── Header ────────────────────────────────────────────── */
.main-header {
  background: linear-gradient(135deg, #1D4ED8 0%, #3B82F6 50%, #1E3A8A 100%);
  padding: 20px 20px 24px;
  position: relative;
  overflow: hidden;
}
.main-header::before {
  content: '';
  position: absolute;
  top: -30px; right: -30px;
  width: 120px; height: 120px;
  border-radius: 50%;
  background: rgba(255,255,255,.1);
}
.main-header::after {
  content: '';
  position: absolute;
  bottom: -20px; left: 10px;
  width: 80px; height: 80px;
  border-radius: 50%;
  background: rgba(255,255,255,.07);
}
.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  z-index: 1;
}
.header-logo { display: flex; align-items: center; gap: 12px; }
.header-logo-icon {
  font-size: 28px;
  background: rgba(255,255,255,.2);
  border-radius: 12px;
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
}
.header-logo h1 { font-size: 22px; font-weight: 800; color: #fff; letter-spacing: -.5px; }
.header-logo h1 a { color: #fff; }
.header-logo p { font-size: 13px; color: rgba(255,255,255,.8); margin-top: 2px; }
.btn-share {
  background: rgba(255,255,255,.2);
  border: 1.5px solid rgba(255,255,255,.4);
  color: #fff;
  border-radius: 20px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  transition: background .15s;
}
.btn-share:hover { background: rgba(255,255,255,.3); }

/* ── Screen toggle ─────────────────────────────────────── */
.screen { display: none; }
.screen.active { display: block; }

/* ── Hero ──────────────────────────────────────────────── */
.hero-card {
  background: linear-gradient(135deg, #1D4ED8, #60A5FA);
  border-radius: var(--radius);
  padding: 28px 24px;
  color: #fff;
  text-align: center;
  margin-bottom: 24px;
}
.hero-title { font-size: 20px; font-weight: 800; margin-bottom: 8px; letter-spacing: -.5px; }
.hero-desc { font-size: 14px; opacity: .85; }

/* ── Form ──────────────────────────────────────────────── */
.form-section {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--brand-dark);
  margin-bottom: 6px;
}
.form-group select,
.form-group input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text);
  background: var(--surface2);
  appearance: none;
}
.form-group select {
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%23999' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
.form-group select:focus,
.form-group input:focus { border-color: var(--brand); outline: none; }
.form-group select:disabled { opacity: .5; background: #f3f3f3; }
.form-group input::placeholder { color: #aaa; }
@media (max-width: 520px) {
  .form-row { grid-template-columns: 1fr; }
}

/* ── Buttons ───────────────────────────────────────────── */
.btn-primary {
  display: block;
  width: 100%;
  padding: 16px;
  background: var(--brand);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  border-radius: var(--radius);
  text-align: center;
  transition: background .2s;
}
.btn-primary:hover { background: #2563EB; }
.btn-primary:active { background: var(--brand-dark); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-outline {
  display: block;
  width: 100%;
  padding: 14px;
  background: var(--surface);
  color: #666;
  font-size: 15px;
  font-weight: 600;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  text-align: center;
}
.btn-outline:hover { background: var(--surface2); }
.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--brand);
  background: var(--brand-light);
  margin-bottom: 16px;
}
.btn-back:hover { background: var(--border); }
.btn-share-result {
  display: block;
  width: 100%;
  padding: 14px;
  background: #059669;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  border-radius: var(--radius);
  text-align: center;
}
.btn-share-result:hover { background: #047857; }
.detail-actions { display: flex; flex-direction: column; gap: 10px; margin: 20px 0; }

/* ── Section title ─────────────────────────────────────── */
.section-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--brand-dark);
  margin-bottom: 16px;
  letter-spacing: -.5px;
}

/* ── Filter bar ────────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  transition: border-color .2s;
}
.filter-bar:focus-within { border-color: var(--brand); }
.filter-icon { font-size: 16px; flex-shrink: 0; }
.filter-bar input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-size: 15px;
  color: var(--text);
}
.filter-bar input::placeholder { color: #aaa; }

/* ── Stats card ────────────────────────────────────────── */
.stats-card {
  background: linear-gradient(135deg, #1D4ED8, #3B82F6);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  color: #fff;
}
.stats-row { display: flex; gap: 12px; }
.stats-row + .stats-row { margin-top: 12px; }
.stat-item {
  flex: 1;
  background: rgba(255,255,255,.15);
  border-radius: var(--radius-sm);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-label { font-size: 12px; opacity: .85; font-weight: 600; }
.stat-value { font-size: 16px; font-weight: 800; }
.stat-high { color: #FDE68A; }
.stat-low { color: #BBF7D0; }

/* ── Trade list ────────────────────────────────────────── */
.trade-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.trade-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px 20px;
  text-align: left;
  box-shadow: var(--shadow-sm);
  transition: transform .15s, box-shadow .15s;
  width: 100%;
  min-width: 0;
  overflow: hidden;
  cursor: pointer;
  border: none;
}
.trade-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.trade-card:active { transform: scale(.99); }
.trade-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.trade-apt-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-right: 12px;
}
.trade-price { font-size: 16px; font-weight: 800; color: var(--brand); white-space: nowrap; }
.trade-card-info {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  color: #666;
  margin-bottom: 4px;
}
.trade-location { font-size: 13px; color: #999; }

/* ── Detail ────────────────────────────────────────────── */
.detail-hero {
  background: linear-gradient(135deg, #1D4ED8, #3B82F6);
  border-radius: var(--radius);
  padding: 32px 24px;
  text-align: center;
  color: #fff;
  margin-bottom: 20px;
}
.detail-apt-name { font-size: 22px; font-weight: 800; margin-bottom: 10px; line-height: 1.3; }
.detail-price { font-size: 28px; font-weight: 900; margin-bottom: 8px; }
.detail-date { font-size: 14px; opacity: .85; }
.detail-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}
.detail-card h3 { font-size: 16px; font-weight: 700; color: var(--brand-dark); margin-bottom: 14px; }
.detail-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid #f0f0f0;
  font-size: 15px;
}
.detail-info-row:last-child { border-bottom: none; }
.detail-info-label { color: var(--text-muted); font-weight: 500; }
.detail-price-text { font-weight: 800; color: var(--brand); }

/* ── Guide cards ───────────────────────────────────────── */
.guide-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}
.guide-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.guide-card h3 { font-size: 15px; font-weight: 700; color: var(--brand-dark); margin-bottom: 10px; }
.guide-card p { font-size: 13px; color: #666; line-height: 1.7; }
@media (max-width: 520px) {
  .guide-grid { grid-template-columns: 1fr; }
}

/* ── Error / Empty / Loading ───────────────────────────── */
.error-box {
  background: #FEF2F2;
  color: #DC2626;
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 16px;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
}
.empty-state { text-align: center; padding: 48px 20px; color: #999; font-size: 15px; }
.loading-box { text-align: center; padding: 60px 20px; }
.spinner {
  display: inline-block;
  width: 40px; height: 40px;
  border: 4px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin-bottom: 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-size: 14px; color: var(--text-muted); font-weight: 500; }

/* ── Footer ────────────────────────────────────────────── */
.main-footer {
  text-align: center;
  padding: 20px;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}
.footer-sub { margin-top: 4px; opacity: .7; font-size: 11px; }

/* ── Toast ─────────────────────────────────────────────── */
.share-toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #333;
  color: #fff;
  padding: 12px 24px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  transition: opacity .3s, transform .3s;
  z-index: 9999;
  pointer-events: none;
}
.share-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Sidebar ───────────────────────────────────────────── */
.app-sidebar {
  position: sticky;
  top: 24px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  scrollbar-width: none;
}
.app-sidebar::-webkit-scrollbar { display: none; }
.sidebar-card { background: var(--surface); border-radius: var(--radius-sm); padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow-sm); border: 1px solid var(--border); }
.sidebar-card h3 { font-size: 14px; font-weight: 700; margin-bottom: 12px; padding-left: 8px; border-left: 3px solid var(--brand); color: var(--text); }
.sidebar-list { list-style: none; padding: 0; margin: 0; }
.sidebar-list li { margin-bottom: 6px; }
.sidebar-list a { display: flex; align-items: flex-start; text-decoration: none; color: var(--text); padding: 7px 8px; border-radius: 8px; transition: background .15s; }
.sidebar-list a:hover { background: var(--brand-light); }
.link-icon { margin-right: 8px; font-size: 15px; flex-shrink: 0; margin-top: 1px; }
.link-content { min-width: 0; overflow: hidden; flex: 1; }
.link-title { display: block; font-size: 13px; font-weight: 600; color: var(--brand); margin-bottom: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link-desc { display: block; font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
