/* FCMIT /chat · Win95 course advisor */

:root {
    --desktop: #008080;
    --win-gray: #c0c0c0;
    --win-light: #ffffff;
    --win-mid: #808080;
    --win-dark: #000000;
    --title-left: #000080;
    --title-right: #1084d0;
    --paper: #ffffff;
    --paper-soft: #f4f4f4;
    --note: #ffffe0;
    --text: #000000;
    --muted: #404040;
    --link: #000080;
    --danger: #800000;
    --ok: #008000;
    --font-ui: "MS Sans Serif", Tahoma, "Microsoft YaHei", Arial, sans-serif;
    --font-mono: "Courier New", Consolas, monospace;
}

* { box-sizing: border-box; }

html,
body {
    margin: 0;
    padding: 0;
    min-height: 100%;
}

body {
    min-height: 100vh;
    padding: 20px 10px;
    display: flex;
    justify-content: center;
    align-items: stretch;
    background: var(--desktop);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 14px;
    overflow-x: hidden;
}

a { color: var(--link); }

.window {
    background: var(--win-gray);
    border-top: 2px solid var(--win-light);
    border-left: 2px solid var(--win-light);
    border-right: 2px solid var(--win-dark);
    border-bottom: 2px solid var(--win-dark);
    box-shadow:
        inset -1px -1px var(--win-mid),
        inset 1px 1px #dfdfdf,
        0 10px 30px rgba(0, 0, 0, 0.3);
}

.chat-window {
    width: 100%;
    max-width: 900px;
    height: calc(100vh - 40px);
    min-height: 600px;
    padding: 2px;
    display: flex;
    flex-direction: column;
}

.title-bar {
    min-height: 26px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 3px 4px 3px 6px;
    color: #fff;
    font-weight: 700;
    background: linear-gradient(90deg, var(--title-left), var(--title-right));
}

.title-bar-brand {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.pixel-icon {
    image-rendering: pixelated;
    flex: 0 0 auto;
}

.title-bar-controls {
    display: flex;
    gap: 2px;
}

.title-bar-controls button {
    width: 22px;
    height: 20px;
    padding: 0;
    line-height: 16px;
    font-weight: 700;
    font-family: var(--font-ui);
    background: var(--win-gray);
    color: #000;
    border-top: 2px solid var(--win-light);
    border-left: 2px solid var(--win-light);
    border-right: 2px solid var(--win-dark);
    border-bottom: 2px solid var(--win-dark);
}

.window-body {
    min-height: 0;
    flex: 1;
    padding: 10px;
    display: flex;
    flex-direction: column;
}

.chat-body {
    gap: 8px;
}

.chat-section {
    min-height: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.chat-intro {
    margin: 0 0 8px;
}

.chat-intro h1 {
    margin: 0 0 4px;
    font-size: 20px;
    line-height: 1.2;
}

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

.chat-list {
    min-height: 0;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 8px;
    padding: 12px;
    background: var(--paper);
    border: 2px inset var(--win-mid);
}

.bubble {
    max-width: 85%;
    margin: 0;
    padding: 8px 10px;
    line-height: 1.6;
    font-size: 14px;
    white-space: pre-wrap;
    word-break: break-word;
    border: 1px solid var(--win-mid);
    color: var(--text);
}

.bubble-user {
    margin-left: auto;
    background: var(--note);
}

.bubble-ai {
    margin-right: auto;
    background: var(--paper-soft);
}

.bubble-tag {
    display: block;
    margin-bottom: 4px;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 700;
    color: var(--title-left);
}

.bubble-user .bubble-tag {
    color: var(--ok);
}

.bubble.loading .bubble-body::after,
.typing-dots::after {
    content: "▌";
    animation: blink 1s steps(1) infinite;
}

@keyframes blink {
    50% { opacity: 0; }
}

.course-cards {
    margin-top: 8px;
    display: grid;
    gap: 8px;
}

.course-card {
    padding: 8px 10px;
    background: var(--win-gray);
    border-top: 2px solid var(--win-light);
    border-left: 2px solid var(--win-light);
    border-right: 2px solid var(--win-dark);
    border-bottom: 2px solid var(--win-dark);
    box-shadow: inset -1px -1px var(--win-mid), inset 1px 1px #dfdfdf;
}

.course-card-title {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    font-weight: 700;
    color: var(--title-left);
}

.stage-badge {
    display: inline-block;
    padding: 1px 6px;
    border: 1px solid #000;
    background: var(--title-left);
    color: #fff;
    font-size: 11px;
    line-height: 1.5;
}

.stage-badge.zero_basic,
.stage-badge.beginner {
    background: var(--ok);
}

.stage-badge.advanced,
.stage-badge.expert {
    background: var(--danger);
}

.dir-tags {
    margin-top: 5px;
}

.dir-tag {
    display: inline-block;
    margin: 3px 4px 0 0;
    padding: 0 5px;
    border: 1px solid var(--win-mid);
    background: var(--paper);
    color: #000;
    font-size: 11px;
}

.course-card-reason {
    margin-top: 5px;
    color: #333;
    font-size: 12px;
    white-space: normal;
}

.course-card .win-btn {
    margin-top: 7px;
    text-decoration: none;
    font-size: 12px;
}

.sources {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px dotted var(--win-mid);
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--muted);
}

.sources strong {
    color: var(--title-left);
}

.sources ul {
    margin: 6px 0 0 16px;
    padding: 0;
}

.sources li {
    margin: 2px 0;
}

.sources-match {
    color: #555;
}

.quick-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 0 8px;
}

.chat-input-wrap {
    padding: 8px;
    background: var(--win-gray);
    border-top: 2px solid var(--win-light);
    border-left: 2px solid var(--win-light);
    border-right: 2px solid var(--win-dark);
    border-bottom: 2px solid var(--win-dark);
}

.chat-input-wrap textarea,
.gate-form input {
    width: 100%;
    color: #000;
    background: #fff;
    border: 2px inset var(--win-mid);
    border-radius: 0;
    padding: 8px;
    font-family: var(--font-ui);
    font-size: 14px;
}

.chat-input-wrap textarea {
    display: block;
    min-height: 76px;
    resize: vertical;
}

.chat-input-wrap textarea:focus,
.gate-form input:focus {
    outline: 1px dotted #000;
    outline-offset: -4px;
}

.chat-input-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 8px;
}

.win-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    padding: 5px 14px;
    background: var(--win-gray);
    color: #000;
    font-family: var(--font-ui);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    border-top: 2px solid var(--win-light);
    border-left: 2px solid var(--win-light);
    border-right: 2px solid var(--win-dark);
    border-bottom: 2px solid var(--win-dark);
}

.win-btn:active {
    border-top: 2px solid var(--win-dark);
    border-left: 2px solid var(--win-dark);
    border-right: 2px solid var(--win-light);
    border-bottom: 2px solid var(--win-light);
}

.win-btn:disabled {
    color: var(--win-mid);
    cursor: not-allowed;
    text-shadow: 1px 1px var(--win-light);
}

.win-btn-primary {
    min-width: 82px;
}

.chip {
    min-height: 24px;
    padding: 3px 10px;
    font-size: 12px;
}

.dialog-window {
    width: min(520px, 100%);
    margin: auto;
    padding: 14px;
    background: var(--win-gray);
    border-top: 2px solid var(--win-light);
    border-left: 2px solid var(--win-light);
    border-right: 2px solid var(--win-dark);
    border-bottom: 2px solid var(--win-dark);
    box-shadow: inset -1px -1px var(--win-mid), inset 1px 1px #dfdfdf;
}

.dialog-title {
    margin-bottom: 8px;
    color: var(--title-left);
    font-size: 18px;
    font-weight: 700;
}

.gate-form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    margin: 12px 0 8px;
}

.error {
    color: var(--danger);
    font-weight: 700;
    margin: 8px 0 0;
}

.status-bar {
    display: grid;
    grid-template-columns: minmax(120px, 1fr) minmax(160px, 1fr) auto;
    gap: 3px;
    padding: 0 2px 2px;
}

.status-panel {
    min-height: 24px;
    padding: 3px 6px;
    background: var(--win-gray);
    border: 1px inset var(--win-mid);
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 12px;
}

.status-panel[data-state="online"] { color: var(--ok); }
.status-panel[data-state="busy"],
.status-panel[data-state="gate"] { color: var(--title-left); }
.status-panel[data-state="offline"],
.status-panel[data-state="error"] { color: var(--danger); }

::-webkit-scrollbar {
    width: 16px;
    height: 16px;
}

::-webkit-scrollbar-track {
    background: var(--win-gray);
    border: 1px inset var(--win-mid);
}

::-webkit-scrollbar-thumb {
    background: var(--win-gray);
    border-top: 2px solid var(--win-light);
    border-left: 2px solid var(--win-light);
    border-right: 2px solid var(--win-dark);
    border-bottom: 2px solid var(--win-dark);
}

@media (max-width: 640px) {
    body {
        padding: 8px;
    }

    .chat-window {
        min-height: calc(100vh - 16px);
        height: calc(100vh - 16px);
    }

    .window-body {
        padding: 8px;
    }

    .chat-intro h1 {
        font-size: 18px;
    }

    .bubble {
        max-width: 100%;
    }

    .gate-form {
        grid-template-columns: 1fr;
    }

    .status-bar {
        grid-template-columns: 1fr;
    }
}
