/* ── Fonts ── */

@font-face {
    font-family: 'Instrument Serif';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url(fonts/instrument-serif-latin.woff2) format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: 'Instrument Serif';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url(fonts/instrument-serif-latin-ext.woff2) format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
    font-family: 'Instrument Serif';
    font-style: italic;
    font-weight: 400;
    font-display: swap;
    src: url(fonts/instrument-serif-italic-latin.woff2) format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: 'Instrument Serif';
    font-style: italic;
    font-weight: 400;
    font-display: swap;
    src: url(fonts/instrument-serif-italic-latin-ext.woff2) format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
    font-family: 'DM Sans';
    font-style: normal;
    font-weight: 300 700;
    font-display: swap;
    src: url(fonts/dm-sans-latin.woff2) format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: 'DM Sans';
    font-style: normal;
    font-weight: 300 700;
    font-display: swap;
    src: url(fonts/dm-sans-latin-ext.woff2) format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
    font-family: 'DM Sans';
    font-style: italic;
    font-weight: 400;
    font-display: swap;
    src: url(fonts/dm-sans-italic-latin.woff2) format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: 'DM Sans';
    font-style: italic;
    font-weight: 400;
    font-display: swap;
    src: url(fonts/dm-sans-italic-latin-ext.woff2) format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ── Brand Tokens ── */

:root {
    /* Kompas V2 brand palette */
    --brand-primary: #0F3A5C;
    --brand-primary-dark: #0A2B45;
    --brand-primary-light: #155a86;
    --accent: #5FBFA3;

    /* Legacy aliases (kept so older selectors keep working) */
    --beard-red: var(--brand-primary);
    --beard-dark: var(--brand-primary-dark);
    --beard-light: var(--brand-primary-light);

    --text-primary: #323130;
    --text-secondary: #605e5c;
    --text-muted: #a19f9d;
    --text-label: #666;

    --bg-body: #FAFAF7;
    --bg-white: #fff;
    --bg-subtle: #EEF5F1;

    --border-light: #edebe9;
    --border-hover: #c8c6c4;
    --border-soft: #ddd;
    --bg-input: #fafafa;
    --radius-sm: 6px;
    --radius-md: 8px;

    --status-success-bg: #dff6dd;
    --status-success-fg: #107c10;
    --status-error-bg: #fde7e9;
    --status-error-fg: #a80000;
    --status-warning-bg: #fed9cc;
    --status-warning-fg: #d83b01;
    --status-info-bg: #deecf9;
    --status-info-fg: #004578;

    --font-body: 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-heading: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* Custom fonts for standalone (non-Outlook) contexts */
body.fonts-branded {
    --font-body: 'DM Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-heading: 'Instrument Serif', Georgia, serif;
}

/* ── Reset ── */

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

body {
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-body);
    padding: 16px;
}

h1 {
    font-family: var(--font-heading);
    font-size: 18px;
    font-weight: 400;
    margin-bottom: 12px;
}

h2 {
    font-family: var(--font-heading);
    font-size: 15px;
    font-weight: 400;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

/* ── Status ── */

.status {
    padding: 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
}

.status--connected {
    background: var(--status-success-bg);
    color: var(--status-success-fg);
}

.status--disconnected {
    background: var(--status-warning-bg);
    color: var(--status-warning-fg);
}

.status--info {
    background: var(--status-info-bg);
    color: var(--status-info-fg);
}

/* ── Buttons ── */

.btn {
    display: inline-block;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}

.btn--primary {
    background: var(--beard-red);
    color: #fff;
    border-radius: var(--radius-md);
    box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}

.btn--primary:hover {
    background: var(--beard-dark);
}

.btn--primary:active {
    transform: translateY(1px);
    box-shadow: none;
}

.btn--secondary {
    background: var(--bg-white);
    color: var(--text-primary);
    border: 1px solid var(--border-soft);
}

.btn--full {
    width: 100%;
    display: block;
    text-align: center;
}

.btn--secondary:hover {
    background: var(--bg-subtle);
}

.btn--small {
    font-size: 12px;
    padding: 4px 10px;
}

button[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn:focus-visible {
    outline: 2px solid var(--beard-red);
    outline-offset: 2px;
}

/* ── Email List ── */

.email-list {
    list-style: none;
}

.email-item {
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
}

.email-item:last-child {
    border-bottom: none;
}

.email-subject {
    font-weight: 600;
    margin-bottom: 2px;
}

.email-from {
    font-size: 12px;
    color: var(--text-secondary);
}

.email-date {
    font-size: 11px;
    color: var(--text-muted);
}

/* ── Loading & Error ── */

.loading {
    text-align: center;
    padding: 20px;
    color: var(--text-secondary);
}

.error {
    padding: 12px;
    border-radius: var(--radius-sm);
    background: var(--status-error-bg);
    color: var(--status-error-fg);
    margin-bottom: 16px;
}

/* ── Forms ── */

.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 4px;
    font-size: 13px;
    color: var(--text-secondary);
}

.form-row {
    display: flex;
    gap: 12px;
}

.form-row .form-group {
    flex: 1;
}

.input {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    background: var(--bg-input);
    transition: border-color 0.2s, box-shadow 0.2s;
}

textarea.input {
    resize: vertical;
    min-height: 100px;
}

select.input {
    height: 36px;
}

textarea.input--small {
    min-height: 0;
}

.input:focus {
    outline: none;
    border-color: var(--beard-red);
    box-shadow: 0 0 0 1px var(--beard-red);
}

/* ── Length Toggle ── */

.length-control {
    display: flex;
    position: relative;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.length-control input[type="radio"] {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.length-control input[type="radio"]:focus-visible + label {
    outline: 2px solid var(--beard-red);
    outline-offset: -2px;
}

.length-control label {
    flex: 1;
    text-align: center;
    padding: 6px 12px;
    margin-bottom: 0;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border-right: 1px solid var(--border-soft);
    background: var(--bg-input);
    color: var(--text-primary);
    transition: background 0.15s, color 0.15s;
}

.length-control label:last-of-type {
    border-right: none;
}

.length-control input[type="radio"]:checked + label {
    background: var(--beard-red);
    color: #fff;
}

/* ── Result ── */

.result-container {
    margin-top: 16px;
    padding: 12px;
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
}

.result-body {
    white-space: pre-wrap;
    padding: 12px;
    background: var(--bg-body);
    border-radius: var(--radius-sm);
    margin: 8px 0;
    font-size: 14px;
    line-height: 1.5;
}

.result-signature {
    padding: 12px;
    margin: 0 0 8px;
    font-size: 14px;
    line-height: 1.5;
    border-top: 1px solid var(--border-light, #e5e5e5);
}

.result-signature img {
    max-width: 100%;
    height: auto;
}

.result-signature img[src]:not([src=""]) {
    display: block;
}

/* Hide broken images: show nothing instead of the broken icon */
.result-signature img {
    position: relative;
    overflow: hidden;
    color: transparent;
}

.result-signature-note {
    font-size: 12px;
    color: var(--text-muted, #888);
    margin: 4px 0 8px;
    padding: 0 12px;
    font-style: italic;
}

.result-body[contenteditable="true"] {
    border: 1px solid transparent;
    cursor: text;
}

.result-body[contenteditable="true"]:hover {
    border-color: var(--border-hover);
}

.result-body[contenteditable="true"]:focus {
    outline: none;
    border-color: var(--beard-red);
    background: var(--bg-white);
}

.result-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.result-actions .btn {
    flex: 1;
    min-width: calc(50% - 4px);
}

.result-actions .btn--secondary {
    flex-basis: 100%;
}

.reply-btn-row {
    display: flex;
    gap: 8px;
    flex-basis: 100%;
}

.reply-btn-row .btn {
    flex: 1;
}

.copy-status {
    font-size: 12px;
    color: var(--status-success-fg);
    margin-top: 4px;
    min-height: 16px;
}

/* ── Feedback ── */

.feedback {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-light);
}

.feedback-buttons {
    display: flex;
    gap: 8px;
}

.feedback-btn {
    flex: 1;
    padding: 6px 12px;
    font-size: 13px;
    background: var(--bg-white);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.feedback-btn:hover {
    background: var(--bg-subtle);
    border-color: var(--border-default);
}

.feedback-comment {
    margin-top: 8px;
}

.feedback-textarea {
    width: 100%;
    padding: 8px;
    font-size: 13px;
    font-family: inherit;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    resize: vertical;
    box-sizing: border-box;
}

.feedback-textarea:focus {
    outline: none;
    border-color: var(--beard-red);
}

.feedback-comment .btn {
    margin-top: 6px;
}

.feedback-thanks {
    font-size: 13px;
    color: var(--status-success-fg);
    padding: 6px 0;
}

/* ── HTMX ── */

.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    display: block;
}

/* ── Brand Header ── */

.brand-header {
    text-align: center;
    margin-bottom: 12px;
}

.brand-icon {
    font-size: 32px;
    color: var(--beard-red);
}

/* ── Topbar ── */

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-light);
}

/* ── Profile Cards ── */

.profile-card {
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    background: var(--bg-white);
    padding: 12px;
    margin-bottom: 8px;
}

.profile-card fieldset {
    border: none;
    padding: 0;
}

.profile-card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--beard-red);
    margin-bottom: 4px;
}

.signature-preview-box {
    padding: 10px;
    background: var(--bg-body);
    border: 1px solid var(--border-light, #e5e5e5);
    border-radius: var(--radius-sm);
    font-size: 13px;
    line-height: 1.5;
    margin: 4px 0 8px;
}

.signature-preview-box img {
    max-width: 100%;
    height: auto;
}

.signature-source {
    color: var(--text-muted, #888);
    font-size: 12px;
}

.profile-card-tone {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.profile-card-summary {
    font-size: 13px;
    line-height: 1.5;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.profile-card-style {
    font-size: 12px;
    font-style: italic;
    color: var(--text-secondary);
    margin-top: 4px;
}

.profile-meta {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

/* ── Tags ── */

.profile-tags-group {
    margin-bottom: 6px;
}

.profile-tags-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 3px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.profile-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.tag {
    display: inline-block;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 500;
    background: var(--bg-subtle);
    border-radius: 10px;
    color: var(--text-primary);
}

/* ── Rules ── */

.rules-hint {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.rule-item {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-bottom: 6px;
}

.rule-item .input {
    flex: 1;
}

.btn-delete {
    background: none;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 16px;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
}

.btn-delete:focus-visible {
    outline: 2px solid var(--beard-red);
    outline-offset: 2px;
}

.btn-delete:hover {
    background: var(--status-error-bg);
    color: var(--status-error-fg);
    border-color: var(--status-error-fg);
}

/* ── Email Context Panel (reply mode) ── */

.email-context-panel {
    background: linear-gradient(135deg, #fef7f6, var(--bg-white));
    border: 1px solid var(--border-light);
    border-left: 3px solid var(--beard-red);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    margin-bottom: 14px;
}

.email-context-header {
    margin-bottom: 6px;
}

.email-context-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #fff;
    background: var(--beard-red);
    padding: 2px 8px;
    border-radius: 10px;
}

.email-context-info {
    font-size: 12px;
}

.email-context-row {
    display: flex;
    gap: 6px;
    align-items: baseline;
    margin-bottom: 2px;
}

.email-context-row:last-child {
    margin-bottom: 0;
}

.email-context-label {
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}

.email-context-value {
    color: var(--text-primary);
    word-break: break-word;
}

.email-context-loading {
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
}

/* Context footer for conversation thread */
.context-footer {
    margin-top: 16px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.context-summary {
    padding: 10px 14px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    background: var(--bg-subtle);
}

.context-summary:hover {
    background: var(--bg-subtle);
    opacity: 0.85;
}

.context-messages {
    padding: 8px 14px;
}

.context-message {
    padding: 8px 0;
    border-bottom: 1px solid var(--border-light);
}

.context-message:last-child {
    border-bottom: none;
}

.context-message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
    font-size: 12px;
}

.context-message-date {
    color: var(--text-secondary);
    font-size: 11px;
}

.context-message-body {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-word;
}

/* ── Quota exceeded ── */

.quota-exceeded {
    text-align: center;
    padding: 24px 16px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    background: var(--bg-white);
    margin-top: 12px;
}

.quota-exceeded-icon {
    color: var(--status-warning-fg);
    margin-bottom: 8px;
}

.quota-exceeded h3 {
    font-family: var(--font-heading);
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.quota-exceeded p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 12px;
}

.quota-upgrade {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
}

.quota-upgrade-pitch {
    font-size: 13px;
    color: var(--text-primary);
    font-weight: 500;
    margin-bottom: 12px;
}

.quota-reset-info {
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
}

/* ── Usage summary (settings) ── */

.usage-summary {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.usage-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
}

.usage-label {
    color: var(--text-secondary);
}

.usage-value {
    font-weight: 600;
    color: var(--text-primary);
}

.usage-bar-container {
    height: 6px;
    background: var(--border-light);
    border-radius: 3px;
    overflow: hidden;
}

.usage-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.usage-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin: 0;
}

/* ── Landing page ── */

.landing {
    max-width: 640px;
    margin: 0 auto;
    padding: 48px 24px;
}

.landing-hero {
    text-align: center;
    margin-bottom: 48px;
}

.landing-hero h1 {
    font-family: var(--font-heading);
    font-size: 32px;
    font-weight: 400;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.landing-hero p {
    font-size: 16px;
    color: var(--text-secondary);
    line-height: 1.6;
    max-width: 480px;
    margin: 0 auto;
}

.landing-features {
    display: grid;
    gap: 16px;
    margin-bottom: 48px;
}

.landing-feature {
    padding: 20px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    background: var(--bg-white);
}

.landing-feature h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.landing-feature p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.landing-pricing {
    text-align: center;
    margin-bottom: 48px;
}

.landing-pricing h2 {
    font-family: var(--font-heading);
    font-size: 22px;
    margin-bottom: 24px;
}

.pricing-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.pricing-card {
    padding: 24px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    background: var(--bg-white);
    text-align: left;
}

.pricing-card--featured {
    border-color: var(--beard-red);
    box-shadow: 0 0 0 1px var(--beard-red);
}

.pricing-card h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}

.pricing-card .price {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.pricing-card .price span {
    font-size: 13px;
    font-weight: 400;
    color: var(--text-secondary);
}

.pricing-card ul {
    list-style: none;
    margin-bottom: 16px;
}

.pricing-card li {
    font-size: 13px;
    color: var(--text-secondary);
    padding: 4px 0;
    padding-left: 20px;
    position: relative;
}

.pricing-card li::before {
    content: "\2713";
    position: absolute;
    left: 0;
    color: var(--status-success-fg);
    font-weight: 600;
}

.landing-footer {
    text-align: center;
    padding-top: 24px;
    border-top: 1px solid var(--border-light);
    font-size: 12px;
    color: var(--text-muted);
}

.landing-footer a {
    color: var(--text-secondary);
    text-decoration: none;
}

.landing-footer a:hover {
    text-decoration: underline;
}

/* ── Legal pages ── */

.legal {
    max-width: 640px;
    margin: 0 auto;
    padding: 48px 24px;
}

.legal h1 {
    font-size: 24px;
    margin-bottom: 24px;
}

.legal h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-top: 24px;
    margin-bottom: 8px;
}

.legal p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 12px;
}
