@font-face {
    font-family: 'Vazirmatn';
    src: url('../fonts/vazirmatn/Vazirmatn[wght].woff2') format('woff2 supports variations'),
         url('../fonts/vazirmatn/Vazirmatn[wght].woff2') format('woff2-variations');
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

:root {
    --ink: #172027;
    --muted: #5d6a72;
    --line: #dce5e2;
    --surface: #ffffff;
    --soft: #f5faf8;
    --teal: #0f766e;
    --teal-dark: #0b5f59;
    --coral: #e85d5d;
    --saffron: #f3b33d;
    --sky: #dff3ff;
    --shadow: 0 18px 50px rgba(23, 32, 39, .08);
    font-family: 'Vazirmatn', Tahoma, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    color: var(--ink);
    background: linear-gradient(180deg, #f8fbfa 0, #fff 46%, #f6f7fb 100%);
    min-height: 100vh;
    line-height: 1.8;
}
a { color: var(--teal); text-decoration: none; }
a:hover { color: var(--teal-dark); }
button, input, textarea, select { font: inherit; }
input, textarea, select {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: .68rem .8rem;
    color: var(--ink);
    background: #fff;
}
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus, button:focus-visible, a:focus-visible {
    outline: 3px solid rgba(15, 118, 110, .22);
    outline-offset: 2px;
}
.skip-link {
    position: fixed;
    right: 1rem;
    top: -4rem;
    background: #fff;
    padding: .6rem 1rem;
    border: 1px solid var(--line);
    z-index: 20;
}
.skip-link:focus { top: 1rem; }
.site-header {
    position: sticky;
    top: 0;
    background: rgba(255,255,255,.92);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--line);
    z-index: 10;
}
.nav-shell, .page-shell, .site-footer {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
}
.nav-shell {
    min-height: 68px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: .7rem;
    color: var(--ink);
    font-weight: 800;
}
.brand-mark {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: var(--teal);
    color: #fff;
}
.nav-links {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .8rem;
}
.page-shell { padding: 28px 0 56px; }
.site-footer {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    color: var(--muted);
    border-top: 1px solid var(--line);
    padding: 22px 0;
}
.button, button.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    border: 0;
    border-radius: 8px;
    padding: .65rem 1rem;
    background: var(--teal);
    color: #fff;
    cursor: pointer;
    font-weight: 700;
}
.button:hover { color: #fff; background: var(--teal-dark); }
.button-muted { background: #e9f3f1; color: var(--teal-dark); }
.button-muted:hover { background: #d9ece8; color: var(--teal-dark); }
.button-danger { background: var(--coral); }
.button-small { min-height: 36px; padding: .42rem .75rem; }
.link-button {
    border: 0;
    background: transparent;
    color: var(--teal);
    cursor: pointer;
    padding: 0;
}
.inline-form { display: inline-flex; gap: .4rem; align-items: center; }
.flash {
    border-radius: 8px;
    padding: .8rem 1rem;
    margin-bottom: 1rem;
    border: 1px solid var(--line);
    background: #fff;
}
.flash-success { border-color: #a7decf; background: #edf9f5; }
.flash-error { border-color: #f2b3b3; background: #fff2f2; }
.assistant-hero {
    display: grid;
    grid-template-columns: minmax(260px, .9fr) minmax(320px, 1.1fr);
    align-items: center;
    gap: 28px;
    min-height: clamp(520px, 82vh, 740px);
}
.assistant-visual {
    min-height: 360px;
    display: grid;
    place-items: center;
    background: radial-gradient(circle at 70% 25%, var(--sky), transparent 38%), linear-gradient(140deg, #eef9f6, #fff7ea);
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}
.assistant-visual img {
    width: min(100%, 520px);
    height: auto;
    display: block;
}
.assistant-panel {
    display: grid;
    gap: 1rem;
}
.assistant-panel h1 {
    font-size: clamp(2rem, 5vw, 4.2rem);
    line-height: 1.25;
    margin: 0;
    letter-spacing: 0;
}
.intent-switch {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .6rem;
}
.intent-option {
    min-height: 52px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    color: var(--ink);
}
.intent-option.active {
    border-color: var(--teal);
    box-shadow: inset 0 0 0 2px rgba(15,118,110,.12);
    color: var(--teal-dark);
    font-weight: 800;
}
.voice-console {
    min-height: 178px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 1rem;
    padding: 1.1rem;
}
.mic-button {
    width: 112px;
    height: 112px;
    border: 0;
    border-radius: 50%;
    background: var(--coral);
    cursor: pointer;
    display: grid;
    place-items: center;
    box-shadow: 0 14px 30px rgba(232, 93, 93, .32);
}
.mic-glyph {
    width: 30px;
    height: 48px;
    border-radius: 18px 18px 10px 10px;
    border: 5px solid #fff;
    position: relative;
}
.mic-glyph::before {
    content: "";
    position: absolute;
    width: 52px;
    height: 34px;
    border: 5px solid #fff;
    border-top: 0;
    border-radius: 0 0 28px 28px;
    right: 50%;
    top: 27px;
    transform: translateX(50%);
}
.mic-glyph::after {
    content: "";
    position: absolute;
    width: 5px;
    height: 18px;
    background: #fff;
    right: 50%;
    top: 58px;
    transform: translateX(50%);
}
[data-state="recording"] .mic-button {
    animation: pulse 1.1s infinite;
    background: var(--teal);
}
[data-state="uploading"] .mic-button,
[data-state="thinking"] .mic-button { background: var(--saffron); }
[data-state="error"] .mic-button { background: #8f2d38; }
.recorder-meta {
    display: grid;
    gap: .2rem;
}
.recorder-meta strong { font-size: 1.1rem; }
.recorder-meta span { color: var(--muted); direction: ltr; text-align: right; }
.wave-line {
    grid-column: 1 / -1;
    height: 32px;
    display: flex;
    align-items: center;
    gap: .35rem;
}
.wave-line span {
    width: 100%;
    max-width: 48px;
    height: 8px;
    border-radius: 99px;
    background: #cfe5e0;
}
.is-recording .wave-line span { animation: bars .9s infinite ease-in-out; }
.is-recording .wave-line span:nth-child(2) { animation-delay: .12s; }
.is-recording .wave-line span:nth-child(3) { animation-delay: .2s; }
.is-recording .wave-line span:nth-child(4) { animation-delay: .32s; }
.is-recording .wave-line span:nth-child(5) { animation-delay: .42s; }
.audio-review, .speak-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .7rem;
    align-items: center;
}
.audio-review audio { flex: 1 1 220px; min-width: 0; }
.text-fallback, .stack-form {
    display: grid;
    gap: .8rem;
}
.text-fallback label span, .stack-form label span, .filter-form label span { display: block; margin-bottom: .25rem; font-weight: 700; }
.check-row {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
}
.check-row input { width: auto; min-height: auto; }
.assistant-message {
    border: 1px solid #b9dfd7;
    background: #eefbf7;
    border-radius: 8px;
    padding: .9rem 1rem;
}
.assistant-message[data-kind="error"] { border-color: #f0bbbb; background: #fff2f2; }
.icon-button {
    width: 44px;
    height: 44px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
}
.latest-band, .preview-card, .form-band, .toolbar-band, .table-wrap, .auth-panel, .error-page {
    margin-top: 1.2rem;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 8px 24px rgba(23,32,39,.05);
}
.preview-form-card {
    border-color: #b9dfd7;
    background: linear-gradient(180deg, #ffffff 0%, #f7fcfb 100%);
}
.preview-head {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--line);
    padding-bottom: .8rem;
}
.preview-head h2 {
    margin: .25rem 0 0;
}
.preview-head p {
    max-width: 360px;
    margin: 0;
    color: var(--muted);
}
.step-pill {
    display: inline-flex;
    border-radius: 8px;
    background: #e9f3f1;
    color: var(--teal-dark);
    padding: .2rem .55rem;
    font-size: .82rem;
    font-weight: 800;
}
.preview-form-grid {
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}
.needs-attention span::after {
    content: " *";
    color: var(--coral);
}
.needs-attention select {
    border-color: var(--coral);
    background: #fff8f8;
}
.confirm-row {
    display: flex;
    align-items: center;
    gap: .8rem;
    flex-wrap: wrap;
    padding-top: .3rem;
}
.confirm-row small {
    color: var(--muted);
}
.alert-form {
    margin-top: 1rem;
    border: 1px solid #b9dfd7;
    border-radius: 8px;
    background: #f3fbf8;
    padding: .9rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}
.alert-form p {
    margin: .15rem 0 0;
    color: var(--muted);
}
.section-heading, .toolbar-band {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}
.section-heading h2, .toolbar-band h1, .form-band h1, .auth-panel h1 { margin: 0; }
.listing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: .8rem;
}
.listing-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    min-height: 190px;
}
.listing-card a {
    min-height: 190px;
    padding: .95rem;
    display: grid;
    color: var(--ink);
}
.listing-thumb {
    width: 100%;
    aspect-ratio: 16 / 10;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: .6rem;
    background: #eef3f2;
}
.listing-card h3 {
    margin: .3rem 0;
    font-size: 1.05rem;
    line-height: 1.6;
}
.listing-card p {
    color: var(--muted);
    margin: 0;
}
.card-topline, .card-footer {
    display: flex;
    justify-content: space-between;
    gap: .7rem;
    color: var(--muted);
    font-size: .88rem;
}
.card-topline strong { color: var(--teal); }
.card-footer b { color: var(--ink); }
.listing-card small { color: var(--teal-dark); align-self: end; }
.filter-form, .form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: .8rem;
    align-items: end;
}
.detail-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 310px;
    gap: 1rem;
}
.detail-main, .contact-panel {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 1rem;
}
.detail-main h1 { margin: .3rem 0; font-size: clamp(1.7rem, 4vw, 3rem); letter-spacing: 0; }
.detail-kicker, .detail-location { color: var(--muted); }
.detail-price { color: var(--teal-dark); font-size: 1.4rem; font-weight: 900; }
.description-text { white-space: normal; }
.detail-media {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: .7rem;
    margin: 1rem 0;
}
.detail-media img,
.detail-media video,
.media-tile img,
.media-tile video {
    width: 100%;
    aspect-ratio: 16 / 10;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #eef3f2;
}
.media-manager {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: .9rem;
    background: #fbfdfc;
}
.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: .7rem;
    margin-top: .7rem;
}
.media-tile {
    display: grid;
    gap: .45rem;
}
.form-hint {
    color: var(--muted);
}
.tag-row { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: 1rem; }
.tag-row span {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: .25rem .55rem;
    color: #334155;
}
.contact-panel dl { display: grid; grid-template-columns: auto 1fr; gap: .35rem .8rem; }
.contact-panel dt { color: var(--muted); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 680px; }
th, td { border-bottom: 1px solid var(--line); text-align: right; padding: .7rem; vertical-align: middle; }
th { color: var(--muted); font-weight: 700; }
.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: .8rem;
    margin-top: 1rem;
}
.metric {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 1rem;
}
.metric span { color: var(--muted); display: block; }
.metric strong { font-size: 1.6rem; }
.empty-state {
    border: 1px dashed var(--line);
    border-radius: 8px;
    padding: 1.2rem;
    background: #fff;
    color: var(--muted);
}
.debug-paths {
    display: block;
    margin-top: .7rem;
    direction: ltr;
    text-align: left;
    overflow-wrap: anywhere;
    color: #64748b;
}
.pagination { display: flex; gap: .5rem; margin-top: 1rem; }
.hidden { display: none !important; }

@keyframes pulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(15,118,110,.34); }
    50% { transform: scale(1.04); box-shadow: 0 0 0 16px rgba(15,118,110,0); }
}
@keyframes bars {
    0%, 100% { height: 8px; }
    50% { height: 28px; }
}

@media (max-width: 820px) {
    .assistant-hero {
        grid-template-columns: 1fr;
        min-height: auto;
    }
    .assistant-visual { min-height: 260px; }
    .detail-layout { grid-template-columns: 1fr; }
    .nav-shell { align-items: flex-start; padding: .8rem 0; }
    .nav-links { justify-content: flex-end; }
}

@media (max-width: 520px) {
    .nav-shell, .page-shell, .site-footer { width: min(100% - 20px, 1180px); }
    .brand span:last-child { max-width: 190px; line-height: 1.5; }
    .intent-switch { grid-template-columns: 1fr; }
    .voice-console {
        grid-template-columns: 1fr;
        text-align: center;
        justify-items: center;
    }
    .mic-button { width: 98px; height: 98px; }
    .assistant-panel h1 { font-size: 2rem; }
    .site-footer { flex-direction: column; }
    .preview-head { display: grid; }
}
