:root {
  --bg: #f9fafb;
  --panel: #ffffff;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --line-strong: #cbd5e1;
  --brand: #2563eb;
  --brand-2: #1d4ed8;
  --accent: #0f766e;
  --coral: #ea580c;
  --violet: #7c3aed;
  --danger: #dc2626;
  --good: #16a34a;
  --shadow: 0 10px 30px rgba(17, 24, 39, .08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a { color: inherit; text-decoration: none; }
button, input, textarea { font: inherit; }

.market-app, .fastcopy-page { min-height: 100vh; }

.market-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 22px;
  align-items: center;
  min-height: 64px;
  padding: 10px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .98);
  backdrop-filter: blur(10px);
}

.brand { display: inline-flex; align-items: center; gap: 10px; min-width: max-content; }
.brand-badge { display: grid; width: 36px; height: 36px; place-items: center; border-radius: 8px; color: white; background: var(--brand); font-weight: 900; }
.brand strong, .brand small { display: block; line-height: 1.05; }
.brand small { color: var(--muted); font-size: 12px; font-weight: 800; text-transform: uppercase; }

.nav-pills { display: flex; gap: 6px; justify-content: center; min-width: 0; overflow-x: auto; }
.nav-pills a {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 13px;
  border-radius: 8px;
  color: #334155;
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
}
.nav-pills a.active, .nav-pills a:hover { background: #eff6ff; color: var(--brand-2); }

.header-actions { display: flex; align-items: center; gap: 10px; justify-content: end; }
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  font-weight: 900;
  cursor: pointer;
}
.button.primary { border-color: var(--brand); background: var(--brand); color: white; }
.button.primary:hover { background: var(--brand-2); }
.button.ghost { background: #f9fafb; }
.icon-button { border: 0; background: transparent; cursor: pointer; }

.user-chip { display: inline-flex; align-items: center; gap: 9px; }
.avatar { width: 34px; height: 34px; border-radius: 8px; object-fit: cover; background: #e2e8f0; }

.assistant-strip {
  display: grid;
  grid-template-columns: minmax(240px, 420px) minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: #111827;
  color: white;
}
.assistant-strip strong { display: block; }
.assistant-strip span { color: #cbd5e1; font-size: 13px; }
.assistant-strip form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
.assistant-strip input {
  min-height: 42px;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 8px;
  padding: 0 14px;
  background: rgba(255,255,255,.08);
  color: white;
  outline: none;
}
.assistant-strip input::placeholder { color: #cbd5e1; }
.assistant-strip button { min-height: 42px; border: 0; border-radius: 8px; padding: 0 18px; background: #14b8a6; color: #042f2e; font-weight: 900; cursor: pointer; }
.assistant-strip button { background: var(--brand); color: white; }

.view-shell { padding: 20px 24px 34px; }
.hero {
  display: grid;
  grid-template-columns: minmax(0, .98fr) minmax(380px, .7fr);
  gap: 16px;
  align-items: stretch;
  margin-bottom: 18px;
}
.hero-main, .hero-side, .card, .panel, .info-card, .market-rail, .insight-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: var(--shadow);
}
.hero-main {
  min-height: 310px;
  padding: 30px;
  color: var(--ink);
  background:
    linear-gradient(115deg, rgba(255,255,255,.97), rgba(239,246,255,.94)),
    url("https://images.unsplash.com/photo-1642790106117-e829e14a795f?auto=format&fit=crop&w=1800&q=80") center / cover;
}
.eyebrow { margin: 0 0 10px; color: var(--brand-2); font-size: 12px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
h1 { max-width: 780px; margin: 0; font-size: clamp(36px, 5.2vw, 62px); line-height: .98; letter-spacing: 0; }
h2 { margin: 0; font-size: 28px; letter-spacing: 0; }
h3 { margin: 0; font-size: 19px; letter-spacing: 0; }
p { line-height: 1.58; }
.hero-main p { max-width: 690px; color: #475569; font-size: 16px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 24px; }
.hero-side { display: grid; align-content: stretch; padding: 0; overflow: hidden; }
.hero-side-head { padding: 18px 18px 0; }
.hero-side-head p { margin: 6px 0 0; color: var(--muted); }
.assistant-preview { display: grid; gap: 10px; padding: 18px; }
.assistant-preview div { border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: #f9fafb; }
.assistant-preview strong { display: block; margin-bottom: 4px; }
.assistant-preview span { color: var(--muted); font-size: 13px; }
.metric-row { display: flex; justify-content: space-between; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.metric-row:last-child { border-bottom: 0; }
.metric-row span { color: var(--muted); }
.metric-row strong { font-size: 22px; }

.section-head { display: flex; justify-content: space-between; align-items: end; gap: 18px; margin: 24px 0 14px; }
.section-head p { margin: 7px 0 0; color: var(--muted); max-width: 720px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.filters button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: white;
  color: #334155;
  font-weight: 900;
  cursor: pointer;
}
.filters button.active { border-color: #bfdbfe; background: #eff6ff; color: var(--brand-2); }

.grid { display: grid; gap: 14px; }
.product-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.seller-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.three-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.market-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 16px; align-items: start; }
.market-rail { position: sticky; top: 94px; padding: 14px; }
.rail-group { display: grid; gap: 7px; margin-top: 12px; }
.rail-group button {
  width: 100%;
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 0 10px;
  background: transparent;
  color: #334155;
  text-align: left;
  font-weight: 800;
  cursor: pointer;
}
.rail-group button.active, .rail-group button:hover { border-color: #bfdbfe; background: #eff6ff; color: var(--brand-2); }
.insight-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 16px 0; }
.insight-card { min-height: 96px; padding: 14px; }
.insight-card span { color: var(--muted); font-size: 13px; font-weight: 800; }
.insight-card strong { display: block; margin-top: 8px; font-size: 25px; }
.insight-card small { color: var(--muted); }

.card { display: flex; flex-direction: column; min-height: 278px; padding: 16px; transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease; }
.card:hover { transform: translateY(-2px); border-color: #bfdbfe; box-shadow: 0 18px 42px rgba(37, 99, 235, .12); }
.card.featured { border-color: #93c5fd; box-shadow: 0 18px 46px rgba(37, 99, 235, .14); }
.topline, .footerline { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.topline { color: var(--brand-2); font-size: 12px; font-weight: 900; text-transform: uppercase; }
.card h3 { margin-top: 10px; line-height: 1.2; }
.seller-line { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.card p { color: #475569; font-size: 14px; }
.badges { display: flex; flex-wrap: wrap; gap: 7px; margin-top: auto; }
.badges span { border: 1px solid var(--line); border-radius: 999px; padding: 5px 8px; color: #374151; background: #f9fafb; font-size: 12px; font-weight: 900; }
.badges .risk-low, .badges .prop-yes { border-color: #bbf7d0; background: #f0fdf4; color: var(--good); }
.badges .risk-medium, .badges .prop-conditional { border-color: #fed7aa; background: #fff7ed; color: var(--coral); }
.badges .risk-high, .badges .risk-very_high, .badges .prop-no { border-color: #fecaca; color: var(--danger); }
.footerline { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.footerline strong { font-size: 21px; }
.footerline span { color: var(--muted); font-weight: 800; font-size: 13px; }

.seller-card { display: grid; grid-template-columns: 74px minmax(0, 1fr); gap: 14px; align-items: center; padding: 16px; border: 1px solid var(--line); border-radius: 8px; background: white; box-shadow: var(--shadow); }
.seller-card img { width: 74px; height: 74px; border-radius: 8px; object-fit: cover; }
.seller-card p { margin: 6px 0; color: var(--muted); }

.detail-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; }
.panel { padding: 22px; }
.detail-title { display: flex; justify-content: space-between; gap: 20px; align-items: start; }
.price-box { border: 1px solid var(--line); border-radius: 8px; padding: 16px; background: #f8fafc; }
.price-box strong { display: block; font-size: 34px; }
.list { display: grid; gap: 9px; margin-top: 14px; }
.list div { display: flex; justify-content: space-between; gap: 12px; padding: 11px; border: 1px solid var(--line); border-radius: 7px; background: #f8fafc; }
.list span { color: var(--muted); }
.review, .discussion-post { border: 1px solid var(--line); border-radius: 8px; padding: 14px; background: white; }
.stars { color: #ca8a04; font-weight: 900; }
.discussion-form { display: grid; gap: 9px; margin-top: 12px; }
.discussion-form textarea, .profile-form textarea, .profile-form input, .auth-form input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 10px 12px;
  outline: none;
}
.discussion-form textarea, .profile-form textarea { min-height: 96px; resize: vertical; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; }
.profile-form { display: grid; gap: 12px; }
.profile-form label, .auth-form label { display: grid; gap: 6px; color: #334155; font-weight: 800; }
.form-message { min-height: 22px; color: var(--muted); }
.form-message.error { color: var(--danger); }
.form-message.ok { color: var(--good); }

.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 20px; background: rgba(15, 23, 42, .62); }
.modal[hidden] { display: none; }
.modal-card { position: relative; width: min(460px, 100%); border-radius: 8px; padding: 20px; background: white; box-shadow: var(--shadow); }
.modal-close { position: absolute; top: 10px; right: 12px; font-size: 28px; }
.modal-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.modal-tabs button { flex: 1; min-height: 38px; border: 1px solid var(--line); border-radius: 7px; background: white; font-weight: 900; cursor: pointer; }
.modal-tabs button.active { background: #ccfbf1; border-color: var(--brand); color: var(--brand-2); }
.auth-form { display: grid; gap: 12px; }

.fastcopy-hero { padding: 72px 28px; color: white; background: linear-gradient(110deg, rgba(8,47,73,.98), rgba(15,118,110,.86)), url("https://images.unsplash.com/photo-1611974789855-9c2a0a7236a3?auto=format&fit=crop&w=1800&q=80") center / cover; }
.fastcopy-hero h1 { max-width: 780px; }
.fastcopy-hero p { max-width: 760px; color: #e2e8f0; font-size: 18px; }
.section-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; padding: 28px; }
.info-card { padding: 20px; }
.detail-band { margin: 0 28px 28px; border: 1px solid var(--line); border-radius: 8px; padding: 28px; background: white; }

@media (max-width: 1120px) {
  .product-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .hero, .detail-layout, .dashboard-grid, .market-layout { grid-template-columns: 1fr; }
  .market-rail { position: static; }
  .rail-group { display: flex; flex-wrap: wrap; }
  .rail-group button { width: auto; }
  .insight-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  .market-header { grid-template-columns: 1fr; gap: 10px; align-items: start; }
  .nav-pills { justify-content: start; }
  .header-actions { justify-content: start; }
  .assistant-strip, .product-grid, .seller-grid, .three-grid, .section-grid, .insight-row { grid-template-columns: 1fr; }
  .view-shell { padding: 14px; }
  .hero-main { min-height: auto; padding: 26px; }
  h1 { font-size: 38px; }
}
