:root {
    --primary: #0f766e;
    --primary-dark: #0b5f59;
    --primary-soft: #e8f5f2;
    --accent: #d6a84b;
    --ink: #17212b;
    --muted: #65717e;
    --line: #e4e9ed;
    --surface: #ffffff;
    --page: #f7f9f9;
    --sidebar-width: 268px;
    --shadow: 0 10px 35px rgba(24, 47, 45, .09);
}

* { box-sizing: border-box; }

html, body {
    height: 100%;
    margin: 0;
}

body {
    color: var(--ink);
    background: var(--page);
    font-family: "Be Vietnam Pro", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
}

button, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }

.app-shell {
    display: flex;
    min-height: 100%;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
    display: flex;
    flex-direction: column;
    width: var(--sidebar-width);
    padding: 22px 16px 16px;
    border-right: 1px solid var(--line);
    background: var(--surface);
}

.brand-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 7px 22px;
}

.brand {
    display: flex;
    gap: 10px;
    align-items: center;
    color: var(--ink);
    font-size: 16px;
    font-weight: 700;
    text-decoration: none;
}

.brand-mark {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border-radius: 10px 10px 10px 3px;
    color: #fff;
    background: linear-gradient(145deg, var(--primary), #159c8f);
    box-shadow: 0 5px 14px rgba(15, 118, 110, .22);
    font-size: 18px;
}

.new-chat {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 43px;
    margin-bottom: 18px;
    padding: 0 14px;
    border: 1px solid #cae5e1;
    border-radius: 11px;
    color: var(--primary-dark);
    background: var(--primary-soft);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: background .2s, transform .2s;
}

.new-chat:hover { background: #dcefeb; }
.new-chat:active { transform: scale(.98); }

.new-chat svg, .nav-item svg, .admin-link svg {
    width: 19px;
    height: 19px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.7;
}

.main-nav { display: grid; gap: 5px; }

.nav-item, .admin-link {
    display: flex;
    align-items: center;
    gap: 11px;
    min-height: 42px;
    padding: 0 13px;
    border: 0;
    border-radius: 9px;
    color: #56636f;
    background: transparent;
    font-size: 13px;
    text-align: left;
    text-decoration: none;
}

button.nav-item { width: 100%; }

.nav-item.active {
    color: var(--primary-dark);
    background: #f0f7f6;
    font-weight: 600;
}

.nav-item.disabled {
    cursor: default;
    opacity: .7;
}

.nav-item em {
    margin-left: auto;
    padding: 3px 6px;
    border-radius: 10px;
    color: #7b6850;
    background: #f7f0e2;
    font-size: 9px;
    font-style: normal;
}

.sidebar-spacer { flex: 1; }

.sidebar-note {
    margin: 0 7px 12px;
    color: #7b8791;
    font-size: 10px;
}

.status-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    margin-right: 5px;
    border-radius: 50%;
    background: #2eb67d;
    box-shadow: 0 0 0 3px rgba(46, 182, 125, .12);
}

.admin-link:hover { background: #f4f6f7; }
.sidebar-close { display: none !important; }

.main-content {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    width: calc(100% - var(--sidebar-width));
    min-height: 100vh;
    margin-left: var(--sidebar-width);
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    height: 58px;
    padding: 0 24px;
}

.menu-button, .mobile-brand { display: none !important; }

.icon-button {
    display: inline-grid;
    width: 38px;
    height: 38px;
    padding: 0;
    place-items: center;
    border: 0;
    border-radius: 10px;
    color: #71808c;
    background: transparent;
    cursor: pointer;
}

.icon-button:hover { background: #edf1f2; }
.icon-button svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.7;
}

.chat-view {
    overflow-y: auto;
    scroll-behavior: smooth;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100%;
    padding: 26px 24px 40px;
    text-align: center;
}

.empty-state.hidden { display: none; }

.legal-symbol {
    display: grid;
    width: 58px;
    height: 58px;
    margin-bottom: 20px;
    place-items: center;
    border: 1px solid #d5e8e5;
    border-radius: 18px;
    color: var(--primary);
    background: linear-gradient(145deg, #fff, #e9f5f3);
    box-shadow: 0 9px 25px rgba(15, 118, 110, .11);
}

.legal-symbol svg {
    width: 30px;
    height: 30px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.5;
}

.empty-state h1 {
    max-width: 680px;
    margin: 0;
    font-size: clamp(24px, 3vw, 34px);
    font-weight: 600;
    letter-spacing: -.7px;
}

.empty-state > p {
    max-width: 590px;
    margin: 13px 0 27px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.75;
}

.suggestions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    width: min(780px, 100%);
}

.suggestions button {
    min-height: 70px;
    padding: 13px 15px;
    border: 1px solid var(--line);
    border-radius: 13px;
    color: #44525d;
    background: rgba(255, 255, 255, .78);
    cursor: pointer;
    font-size: 11px;
    line-height: 1.55;
    text-align: left;
    transition: border-color .2s, box-shadow .2s, transform .2s;
}

.suggestions button:hover {
    border-color: #b6d7d2;
    box-shadow: 0 7px 20px rgba(24, 47, 45, .07);
    transform: translateY(-2px);
}

.messages {
    display: none;
    width: min(820px, calc(100% - 40px));
    margin: 0 auto;
    padding: 18px 0 30px;
}

.messages.visible { display: block; }

.message {
    display: flex;
    gap: 12px;
    margin: 0 0 25px;
    animation: message-in .28s ease-out;
}

@keyframes message-in {
    from { opacity: 0; transform: translateY(7px); }
}

.message.user { justify-content: flex-end; }

.message-avatar {
    display: grid;
    flex: 0 0 31px;
    width: 31px;
    height: 31px;
    place-items: center;
    border-radius: 9px;
    color: #fff;
    background: var(--primary);
    font-size: 12px;
    font-weight: 700;
}

.message-content {
    max-width: calc(100% - 45px);
    color: #27343e;
    font-size: 13px;
    line-height: 1.8;
}

.message.user .message-content {
    max-width: min(78%, 620px);
    padding: 11px 15px;
    border: 1px solid #d9e9e6;
    border-radius: 15px 15px 4px 15px;
    color: #263b39;
    background: #eaf5f3;
}

.message-content p { margin: 0 0 10px; }
.message-content p:last-child { margin-bottom: 0; }
.message-content ul, .message-content ol { margin: 8px 0; padding-left: 22px; }
.message-content strong { color: #172b29; font-weight: 600; }

.typing-cursor::after {
    content: "";
    display: inline-block;
    width: 2px;
    height: 1.05em;
    margin-left: 3px;
    background: var(--primary);
    vertical-align: -.15em;
    animation: blink .7s steps(1) infinite;
}

@keyframes blink { 50% { opacity: 0; } }

.thinking {
    display: flex;
    gap: 5px;
    padding-top: 8px;
}

.thinking i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #8a9b9a;
    animation: bounce 1.1s infinite ease-in-out;
}

.thinking i:nth-child(2) { animation-delay: .14s; }
.thinking i:nth-child(3) { animation-delay: .28s; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-5px); } }

.composer-area {
    padding: 13px max(24px, calc((100% - 840px) / 2)) 15px;
    background: linear-gradient(to bottom, rgba(247, 249, 249, 0), var(--page) 18%);
}

.composer {
    position: relative;
    padding: 12px 13px 8px;
    border: 1px solid #dce3e5;
    border-radius: 17px;
    background: var(--surface);
    box-shadow: var(--shadow);
    transition: border-color .2s, box-shadow .2s;
}

.composer:focus-within {
    border-color: #9ccbc5;
    box-shadow: 0 10px 35px rgba(15, 118, 110, .12);
}

.composer textarea {
    display: block;
    width: 100%;
    max-height: 160px;
    padding: 0 3px;
    resize: none;
    overflow-y: auto;
    border: 0;
    outline: 0;
    color: var(--ink);
    background: transparent;
    font-size: 13px;
    line-height: 1.6;
}

.composer textarea::placeholder { color: #9aa5ad; }

.composer-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 8px;
}

.law-badge {
    display: flex;
    align-items: center;
    gap: 5px;
    color: #697780;
    font-size: 9px;
}

.law-badge svg {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: var(--primary);
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.7;
}

.composer-actions { display: flex; align-items: center; gap: 10px; }
.counter { color: #a2abb2; font-size: 9px; }

.send-button {
    display: grid;
    width: 33px;
    height: 33px;
    padding: 0;
    place-items: center;
    border: 0;
    border-radius: 10px;
    color: #fff;
    background: var(--primary);
    cursor: pointer;
    transition: background .2s, transform .2s;
}

.send-button:hover { background: var(--primary-dark); }
.send-button:active { transform: scale(.94); }
.send-button:disabled { cursor: not-allowed; opacity: .5; }
.send-button svg {
    width: 17px;
    height: 17px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.7;
}

.disclaimer {
    margin: 8px 0 0;
    color: #98a2aa;
    font-size: 9px;
    text-align: center;
}

.toast {
    position: fixed;
    z-index: 60;
    right: 22px;
    bottom: 22px;
    max-width: 360px;
    padding: 11px 15px;
    border-radius: 10px;
    color: #fff;
    background: #26333b;
    box-shadow: 0 10px 30px rgba(0,0,0,.18);
    font-size: 12px;
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
    transition: .25s;
}

.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #a83d3d; }
.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.sidebar-backdrop { display: none; }

@media (max-width: 800px) {
    .sidebar {
        width: min(290px, 86vw);
        transform: translateX(-101%);
        transition: transform .25s ease;
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-close { display: inline-grid !important; }
    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        z-index: 20;
        display: block;
        background: rgba(18, 30, 32, .35);
        opacity: 0;
        pointer-events: none;
        transition: opacity .25s;
    }
    .sidebar-backdrop.open { opacity: 1; pointer-events: auto; }
    .main-content { width: 100%; margin-left: 0; }
    .topbar {
        justify-content: space-between;
        height: 54px;
        padding: 0 14px;
        border-bottom: 1px solid rgba(228, 233, 237, .8);
        background: rgba(247, 249, 249, .88);
        backdrop-filter: blur(10px);
    }
    .menu-button { display: inline-grid !important; }
    .mobile-brand { display: block !important; font-size: 13px; font-weight: 700; }
    .suggestions { grid-template-columns: 1fr; max-width: 430px; }
    .suggestions button { min-height: 54px; }
    .composer-area { padding: 10px 12px 12px; }
    .disclaimer { line-height: 1.45; }
}

@media (max-width: 480px) {
    .empty-state { justify-content: flex-start; padding-top: 10vh; }
    .empty-state h1 { font-size: 23px; line-height: 1.35; }
    .empty-state > p { margin-bottom: 20px; font-size: 12px; }
    .suggestions button:nth-child(3) { display: none; }
    .messages { width: calc(100% - 26px); padding-top: 10px; }
    .message-content { font-size: 12px; }
    .message.user .message-content { max-width: 87%; }
    .law-badge { max-width: 145px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        animation-duration: .01ms !important;
        transition-duration: .01ms !important;
    }
}
