@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --accent: #e07840;
    --accent-dark: #c06030;
    --bg: #0d0d0d;
    --surface: #1a1a1a;
    --text: #f0f0f0;
    --text-muted: #888888;
    --border: #2a2a2a;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.4);
    --shadow-lg: 0 4px 24px rgba(0,0,0,0.5);
}

body {
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

.app {
    max-width: 720px;
    margin: 0 auto;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
}

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.header-left { display: flex; align-items: center; gap: 12px; }
.logo { display: flex; align-items: center; gap: 8px; }
.logo-img { width: 32px; height: 32px; object-fit: contain; }
.logo-text { font-weight: 700; font-size: 17px; color: var(--text); }
.subtitle { font-size: 13px; color: var(--text-muted); }

.btn-new {
    display: flex; align-items: center; gap: 4px;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    font-size: 13px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
}
.btn-new:hover { border-color: var(--accent); color: var(--accent); }

/* Progress */
.progress-container {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 20px;
    border-bottom: 1px solid var(--border);
}
.progress-bar {
    flex: 1; height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #e07840, #2a7f8a);
    border-radius: 3px;
    transition: width 0.5s ease;
}
.progress-label { font-size: 12px; color: var(--text-muted); min-width: 32px; text-align: right; }

/* Chat Area */
.chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.chat-welcome {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    height: 100%; text-align: center; gap: 16px;
}
.chat-welcome h2 { font-size: 22px; color: var(--text); }
.chat-welcome p { font-size: 14px; color: var(--text-muted); max-width: 360px; line-height: 1.5; }

.btn-start {
    padding: 12px 32px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-start:hover { background: var(--accent-dark); }

/* Messages */
.messages { display: flex; flex-direction: column; gap: 12px; }

.msg {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    line-height: 1.55;
    animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.msg-assistant {
    align-self: flex-start;
    background: #232323;
    color: #f0f0f0;
    border-bottom-left-radius: 4px;
}

.msg-user {
    align-self: flex-end;
    background: #e07840;
    color: white;
    border-bottom-right-radius: 4px;
}

.msg-loading {
    align-self: flex-start;
    background: #232323;
    padding: 12px 20px;
    border-bottom-left-radius: 4px;
}

.typing-dots { display: flex; gap: 4px; align-items: center; }
.typing-dots span {
    width: 6px; height: 6px;
    background: #e07840;
    border-radius: 50%;
    opacity: 0.4;
    animation: blink 1.2s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes blink {
    0%, 60%, 100% { opacity: 0.4; }
    30% { opacity: 1; }
}

.slow-hint {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Input Area */
.input-area {
    padding: 12px 20px 16px;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

.options-row {
    display: flex; flex-wrap: wrap; gap: 6px;
    margin-bottom: 10px;
}

.option-btn {
    padding: 8px 14px;
    min-height: 44px;
    border: 1px solid #e07840;
    border-radius: 20px;
    background: var(--surface);
    color: #e07840;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
}
.option-btn:hover { background: #e07840; color: #0d0d0d; }

.option-btn-idk {
    border-color: var(--text-muted);
    color: var(--text-muted);
    border-style: dashed;
    font-size: 13px;
}
.option-btn-idk:hover { background: var(--text-muted); color: var(--surface); border-style: dashed; }

.input-form {
    display: flex; gap: 8px;
}

#userInput {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #2a2a2a;
    border-radius: 8px;
    font-size: 16px;
    outline: none;
    transition: border-color 0.15s;
    -webkit-appearance: none;
    background: #1a1a1a;
    color: #f0f0f0;
}
#userInput:focus { border-color: #e07840; }
#userInput::placeholder { color: var(--text-muted); }

.btn-send {
    width: 44px; height: 44px;
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    background: #e07840;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
    -webkit-tap-highlight-color: transparent;
}
.btn-send:hover { background: var(--accent-dark); }
.btn-send:disabled { background: var(--border); cursor: not-allowed; }

.btn-back {
    width: 36px; height: 36px;
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
}
.btn-back:hover { background: #232323; color: var(--accent); border-color: var(--accent); }
.btn-back:disabled { opacity: 0.4; cursor: not-allowed; }

/* Download Bar */
.download-bar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    background: #1a1a1a;
}
.download-bar span { font-size: 14px; font-weight: 600; color: #e07840; }

.btn-download {
    display: flex; align-items: center; gap: 6px;
    padding: 8px 16px;
    background: #e07840;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-download:hover { background: var(--accent-dark); }

.btn-ifu {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px;
    background: var(--surface);
    color: var(--accent);
    border: 1.5px solid var(--accent);
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.btn-ifu:hover { background: var(--accent); color: #0d0d0d; }

/* Footer */
.site-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 4px;
    padding: 10px 20px;
    font-size: 12px;
    color: var(--text-muted);
    background: #0d0d0d;
    text-align: center;
}
.site-footer a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.15s;
}
.site-footer a:hover { color: var(--accent); }
.footer-sep { color: var(--border); margin: 0 2px; }

/* Markdown-like formatting in messages */
.msg strong, .msg b { font-weight: 600; }

/* Header actions */
.header-actions { display: flex; align-items: center; gap: 8px; }
.btn-about-link {
    text-decoration: none;
    font-weight: 500;
}
.btn-about-link.active {
    border-color: var(--accent);
    color: var(--accent);
}

/* About Page */
body:has(.about-page) { height: auto; overflow: auto; }
.about-page { height: auto; min-height: 100vh; min-height: 100dvh; overflow: visible; }
.about-page .header { position: sticky; top: 0; z-index: 10; }

.about-content {
    flex: 1;
    overflow-y: auto;
    padding: 32px 24px;
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.about-intro { text-align: center; max-width: 560px; margin: 0 auto; }
.about-intro h1 { font-size: 24px; color: #e07840; margin-bottom: 10px; }
.about-intro p { font-size: 14px; color: var(--text-muted); line-height: 1.6; }

/* Flow Diagram */
.flow-diagram {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
}
.flow-start, .flow-end {
    display: flex;
    flex-direction: column;
    align-items: center;
}
.flow-node {
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
}
.flow-node small { display: block; font-weight: 400; font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.flow-node-start {
    background: #232323;
    border: 2px solid #e07840;
    color: #f0f0f0;
}
.flow-arrow {
    width: 2px;
    height: 24px;
    background: #e07840;
    position: relative;
}
.flow-arrow::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid #e07840;
}
.flow-branches {
    display: flex;
    gap: 16px;
    justify-content: center;
    position: relative;
    padding: 0 8px;
}
.flow-branches::before {
    content: "";
    position: absolute;
    top: 0;
    left: calc(12.5% + 4px);
    right: calc(12.5% + 4px);
    height: 2px;
    background: #e07840;
}
.flow-branch {
    display: flex;
    flex-direction: column;
    align-items: center;
}
.flow-connector {
    width: 2px;
    height: 20px;
    background: #e07840;
}
.flow-node-branch {
    min-width: 52px;
    height: 40px;
    padding: 0 10px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-align: center;
}
.branch-mdr { background: #e07840; }
.branch-ivdr { background: #3a9fb0; }
.branch-ai { background: #9b59d0; }
.branch-gdpr { background: #27ae72; }

/* Regulation Cards */
.regulation-cards {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.regulation-card {
    display: flex;
    gap: 16px;
    padding: 20px;
    border-radius: var(--radius);
    border: 1px solid #2a2a2a;
    background: #1a1a1a;
    box-shadow: var(--shadow);
}
.card-number {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 16px;
    flex-shrink: 0;
}
.card-mdr .card-number { background: #e07840; }
.card-ivdr .card-number { background: #3a9fb0; }
.card-ai .card-number { background: #9b59d0; }
.card-gdpr .card-number { background: #27ae72; }

.card-body { flex: 1; min-width: 0; }
.card-body h2 { font-size: 17px; color: var(--text); margin-bottom: 6px; }
.card-tag { font-size: 12px; font-weight: 400; color: var(--text-muted); }
.card-body > p { font-size: 13px; color: var(--text-muted); line-height: 1.5; margin-bottom: 12px; }

.card-detail { background: #121212; border-radius: 8px; padding: 14px; }
.card-detail h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); margin-bottom: 8px; }
.card-detail ul { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.card-detail li { font-size: 13px; line-height: 1.5; padding-left: 14px; position: relative; }
.card-detail li::before { content: ""; position: absolute; left: 0; top: 7px; width: 6px; height: 6px; border-radius: 50%; background: var(--border); }
.card-mdr .card-detail li::before { background: #e07840; }
.card-ivdr .card-detail li::before { background: #3a9fb0; }
.card-ai .card-detail li::before { background: #9b59d0; }
.card-gdpr .card-detail li::before { background: #27ae72; }

.class-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip {
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}
.chip-low { background: #0d2a1a; color: #4ade80; }
.chip-mid { background: #2a1a00; color: #fb923c; }
.chip-high { background: #2a0d0d; color: #f87171; }

.about-note {
    text-align: center;
    padding: 20px;
    background: #1a1a1a;
    border-radius: var(--radius);
}
.about-note p { font-size: 13px; color: var(--text-muted); line-height: 1.5; margin-bottom: 16px; }
.about-note .btn-start { display: inline-block; text-decoration: none; }

/* Abbreviations section */
.abbrev-section {
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 12px;
    padding: 20px;
    margin: 0;
}
.abbrev-section h2 {
    font-size: 16px;
    color: #e07840;
    margin-bottom: 14px;
}
.abbrev-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.abbrev-table th {
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    padding: 6px 10px;
    border-bottom: 1px solid #2a2a2a;
}
.abbrev-table td {
    padding: 8px 10px;
    border-bottom: 1px solid #2a2a2a;
    vertical-align: top;
    line-height: 1.5;
    color: var(--text);
}
.abbrev-table tr:last-child td { border-bottom: none; }
.abbrev-table td:first-child {
    font-weight: 700;
    color: #e07840;
    white-space: nowrap;
    width: 90px;
}

/* Risk chips */
/* Responsive */
@media (max-width: 760px) {
    .app { max-width: 100%; box-shadow: none; }
    .subtitle { display: none; }
    .header { padding: 10px 14px; }
    .chat-area { padding: 14px; }
    .input-area { padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px)); }
    .progress-container { padding: 8px 14px; }
    .download-bar { padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px)); }
    .about-content { padding: 24px 14px; gap: 24px; }
    .regulation-card { flex-direction: column; gap: 10px; }
    .flow-branches { gap: 10px; }
    .flow-node-branch { min-width: 44px; height: 34px; font-size: 11px; }
}

@media (max-width: 420px) {
    .logo-text { font-size: 15px; }
    .chat-welcome h2 { font-size: 19px; }
    .chat-welcome p { font-size: 13px; }
    .btn-start { padding: 11px 24px; font-size: 14px; }
    .msg { max-width: 90%; font-size: 14px; }
    .option-btn { padding: 10px 14px; font-size: 13px; }
    .download-bar { flex-wrap: wrap; gap: 8px; justify-content: center; }
}
