/* PaperFriend styles */

* {
    box-sizing: border-box;
}

/* The HTML `hidden` attribute must always win, even over rules like
   `.modal-backdrop { display: flex }`. Without this, hidden panels (and the
   New-paper modal's Cancel button) appear to do nothing. */
[hidden] {
    display: none !important;
}

body {
    background-color: #6200ff;
    background-image: linear-gradient(160deg, #6200ff 0%, #3b0099 100%);
    font-family: Arial, Helvetica, sans-serif;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    min-height: 100dvh;
    color: #fff;
    overflow-x: hidden;
}

/* ---------- floating background blobs ---------- */
.blob {
    position: fixed;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.5;
    z-index: 0;
    pointer-events: none;
    animation: float 14s ease-in-out infinite;
}

.blob-1 { width: 320px; height: 320px; background: #b388ff; top: -80px; left: -60px; }
.blob-2 { width: 260px; height: 260px; background: #7c4dff; bottom: -70px; right: -40px; animation-delay: -4s; }
.blob-3 { width: 200px; height: 200px; background: #e040fb; top: 40%; right: 20%; animation-delay: -8s; }

@keyframes float {
    0%, 100% { transform: translate(0, 0); }
    50%      { transform: translate(20px, -30px); }
}

/* ---------- login card ---------- */
.container {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 20px;
}

.card {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.18);
    backdrop-filter: blur(10px);
    border-radius: 18px;
    padding: 36px 32px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
    animation: pop-in 0.5s ease;
}

@keyframes pop-in {
    from { opacity: 0; transform: translateY(18px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.logo {
    margin: 0;
    text-align: center;
    font-size: 2rem;
    letter-spacing: 0.5px;
}

.logo.small {
    font-size: 1.3rem;
}

.tagline {
    margin: 6px 0 22px;
    text-align: center;
    font-size: 0.9rem;
    opacity: 0.8;
}

/* ---------- tabs with a sliding pill ---------- */
.tabs, .mode-tabs {
    position: relative;
    display: flex;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    padding: 4px;
    margin-bottom: 22px;
}

.mode-tabs {
    margin-bottom: 0;
    width: 150px;
}

.tab-pill {
    position: absolute;
    top: 4px;
    left: 4px;
    width: calc(50% - 4px);
    height: calc(100% - 8px);
    background: #fff;
    border-radius: 8px;
    transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 0;
}

.tab-pill.right {
    transform: translateX(100%);
}

.tab {
    position: relative;
    z-index: 1;
    flex: 1;
    padding: 9px 0;
    border: none;
    background: transparent;
    color: #fff;
    font-size: 0.9rem;
    border-radius: 8px;
    cursor: pointer;
    transition: color 0.25s;
}

.tab.active {
    color: #6200ff;
    font-weight: bold;
}

/* ---------- sliding forms ---------- */
.forms {
    position: relative;
    width: 100%;
    min-width: 0;
    transition: height 0.32s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.form-pane {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateX(40px);
    pointer-events: none;
    transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.28s ease;
}

#signup-form { transform: translateX(40px); }
#login-form  { transform: translateX(-40px); }

.form-pane.active {
    position: relative;
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}

.form-pane input::placeholder { color: rgba(255, 255, 255, 0.58); opacity: 1; }

label {
    font-size: 0.8rem;
    margin-bottom: 5px;
    opacity: 0.85;
}

input {
    display: block;
    width: 100%;
    min-height: 44px;
    padding: 11px 12px;
    margin-bottom: 16px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 0.95rem;
    transition: border 0.2s, background 0.2s;
}

input:focus {
    outline: none;
    border-color: #fff;
    background: rgba(255, 255, 255, 0.2);
}

.btn {
    display: inline-block;
    padding: 12px;
    border: none;
    border-radius: 9px;
    background: #fff;
    color: #6200ff;
    font-size: 0.95rem;
    font-weight: bold;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: transform 0.15s, box-shadow 0.2s, opacity 0.2s;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.3);
}

.btn:active { transform: translateY(0); }

.btn.ghost {
    background: transparent;
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.btn.ghost:hover { background: rgba(255, 255, 255, 0.12); }

.btn.wide { width: 100%; margin-top: 6px; }

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ---------- messages ---------- */
.message {
    min-height: 18px;
    margin: 12px 0 0;
    font-size: 0.82rem;
    text-align: center;
}

.message.error { color: #ffb3c1; }
.message.ok    { color: #b9f6ca; }

.shake { animation: shake 0.4s; }

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-8px); }
    40%, 80% { transform: translateX(8px); }
}

/* ---------- topbar ---------- */
.topbar {
    position: relative;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 26px;
    background: rgba(0, 0, 0, 0.18);
    gap: 14px;
    flex-wrap: wrap;
}

.topbar-left, .topbar-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.hello { font-size: 0.9rem; opacity: 0.9; }

.account-badge {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-width: 130px;
    padding: 6px 11px 6px 7px;
    border: 1px solid rgba(255,255,255,.2);
    border-radius: 999px;
    background: rgba(255,255,255,.1);
}
.account-badge.compact { min-width: 0; }
.account-avatar { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: #fff; color: #6200ff; font-size: .72rem; font-weight: 800; }
.account-copy { display: grid; line-height: 1.05; }
.account-copy small { font-size: .62rem; opacity: .6; }
.account-copy strong, .account-badge > strong { max-width: 130px; overflow: hidden; text-overflow: ellipsis; font-size: .84rem; }
.legal-links { margin: 20px 0 0; text-align: center; font-size: .75rem; opacity: .7; }
.legal-links a { color: #fff; }

.save-state { font-size: 0.8rem; opacity: 0.8; }
.save-state.ok { color: #b9f6ca; }

/* ---------- dashboard ---------- */
.home {
    position: relative;
    z-index: 1;
    max-width: 920px;
    margin: 0 auto;
    padding: 40px 24px 60px;
}

.hero { text-align: center; }
.hero h1 { font-size: 2.4rem; margin: 0 0 6px; }

.library-bar {
    display: flex;
    justify-content: flex-end;
    margin: 28px 0 18px;
}

.library {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 18px;
}

.paper-card {
    position: relative;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    padding: 20px 20px 18px;
    cursor: pointer;
    text-align: left;
    transition: transform 0.18s, box-shadow 0.2s, background 0.2s;
    animation: rise 0.45s ease both;
}

.paper-card:hover {
    transform: translateY(-3px);
    background: rgba(255, 255, 255, 0.13);
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.3);
}

.paper-card:focus { outline: 2px solid #fff; outline-offset: 2px; }

.card-title {
    margin: 12px 0 8px;
    font-size: 1.15rem;
    line-height: 1.3;
}

.card-snippet {
    margin: 0 0 14px;
    font-size: 0.85rem;
    opacity: 0.78;
    line-height: 1.45;
}

.card-meta { margin: 0; font-size: 0.75rem; opacity: 0.6; }

.card-del {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 26px;
    height: 26px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.25);
    color: #fff;
    font-size: 0.8rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s, background 0.2s;
}

.paper-card:hover .card-del { opacity: 1; }
.card-del:hover { background: rgba(255, 82, 82, 0.7); }

/* ---------- format badges ---------- */
.fmt-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: bold;
    letter-spacing: 0.4px;
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
}

.fmt-mla     { background: #7c4dff; }
.fmt-apa     { background: #e040fb; }
.fmt-chicago { background: #ff7043; }
.fmt-basic   { background: #26a69a; }
.fmt-email   { background: #1976d2; }

/* ---------- empty state ---------- */
.empty { text-align: center; opacity: 0.85; padding: 40px 0; }
.empty-big { font-size: 1.2rem; margin: 0 0 6px; }
.empty-small { font-size: 0.9rem; opacity: 0.7; margin: 0; }

/* ---------- new-paper modal ---------- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 20;
    background: rgba(20, 0, 50, 0.55);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fade 0.2s ease;
}

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.modal {
    background: linear-gradient(160deg, #5a14e0, #3b0099);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 18px;
    padding: 28px;
    width: 100%;
    max-width: 460px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
    animation: pop-in 0.3s ease;
}

.modal h2 { margin: 0 0 4px; }
.modal-sub { margin: 0 0 20px; font-size: 0.85rem; opacity: 0.8; }

.format-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 18px;
}

.format-opt {
    display: flex;
    flex-direction: column;
    gap: 6px;
    text-align: left;
    padding: 16px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.07);
    color: #fff;
    cursor: pointer;
    transition: transform 0.15s, background 0.2s, border 0.2s;
}

.format-opt:hover {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.15);
    border-color: #fff;
}

.fo-name { font-size: 1.1rem; font-weight: bold; }
.fo-blurb { font-size: 0.78rem; opacity: 0.8; line-height: 1.4; }

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

/* =====================================================================
   EDITOR — the white page. Same app, but here the paper is white and the
   text is normal dark ink. Fonts are fixed per format (no picker).
   ===================================================================== */
.editor-body {
    background: linear-gradient(160deg, #2a006b 0%, #1a0040 100%);
}

.vocab-bar {
    position: relative;
    z-index: 4;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
    padding: 8px 20px;
    font-size: 0.8rem;
    background: rgba(0, 0, 0, 0.2);
}

.vocab-count { opacity: 0.85; }
.vocab-count.has { color: #ffd24f; font-weight: bold; opacity: 1; }
.vocab-hint { opacity: 0.6; }
.model-state {
    padding: 3px 9px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.1);
    opacity: 0.75;
}
.model-state.ready { color: #b9f6ca; opacity: 1; }

.writing-toolbar {
    position: relative;
    z-index: 4;
    display: flex;
    justify-content: center;
    align-items: end;
    gap: 12px;
    flex-wrap: wrap;
    padding: 9px 18px;
    background: rgba(0, 0, 0, 0.13);
}

.writing-toolbar label { display: grid; gap: 4px; margin: 0; color: rgba(255,255,255,.75); }
.writing-toolbar select, .ai-select {
    border: 1px solid rgba(255,255,255,.24);
    border-radius: 7px;
    padding: 6px 8px;
    color: #fff;
    background: #3a1176;
}

/* ---------- owner dashboard ---------- */
.owner-page { position: relative; z-index: 1; max-width: 1050px; margin: 0 auto; padding: 36px 24px 70px; }
.owner-hero { margin-bottom: 24px; }
.owner-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 18px; }
.stat-card, .owner-panel { background: rgba(255,255,255,.09); border: 1px solid rgba(255,255,255,.16); border-radius: 15px; backdrop-filter: blur(8px); }
.stat-card { padding: 20px; text-align: center; }
.stat-card strong { display: block; font-size: 2rem; }
.stat-card span { opacity: .7; font-size: .82rem; }
.owner-panel { padding: 22px; margin-bottom: 18px; }
.owner-panel h2 { margin: 0 0 4px; }
.owner-panel p { margin: 0; opacity: .72; font-size: .84rem; }
.owner-panel-head { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-bottom: 16px; }
.training-input { width: 100%; min-height: 190px; resize: vertical; border: 1px solid rgba(255,255,255,.22); border-radius: 10px; padding: 14px; background: rgba(0,0,0,.22); color: #fff; line-height: 1.5; }
.owner-note { margin-top: 9px !important; }
.account-list { display: grid; gap: 9px; }
.account-row { display: flex; justify-content: space-between; gap: 16px; align-items: center; padding: 13px; background: rgba(0,0,0,.16); border-radius: 10px; }
.account-row.banned { border-left: 4px solid #ff6b7d; opacity: .8; }
.account-info { display: grid; gap: 3px; }
.account-info span { font-size: .76rem; opacity: .65; }
.account-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.mini-btn { border: 1px solid rgba(255,255,255,.25); border-radius: 7px; padding: 6px 9px; background: rgba(255,255,255,.08); color: #fff; cursor: pointer; }
.mini-btn.danger { color: #ffc2ca; border-color: rgba(255,100,120,.5); }
.owner-view-modal { max-width: 660px; max-height: 80vh; overflow: auto; }
.owner-paper-preview { background: rgba(0,0,0,.18); border-radius: 9px; padding: 12px; margin: 10px 0; }
.owner-paper-preview h3 { margin: 0 0 6px; }
.owner-paper-preview p { white-space: pre-wrap; opacity: .75; font-size: .82rem; }

/* ---------- owner AI trainer ---------- */
.trainer-grid { display: grid; grid-template-columns: 180px 1fr; gap: 12px; align-items: end; }
.trainer-grid label { display: grid; gap: 6px; margin: 0; }
.trainer-grid .trainer-wide { grid-column: 1 / -1; }
.trainer-grid textarea, .ai-test-row textarea { width: 100%; min-height: 80px; resize: vertical; border: 1px solid rgba(255,255,255,.22); border-radius: 9px; padding: 11px; background: rgba(0,0,0,.2); color: #fff; }
.training-count { padding: 5px 10px; border-radius: 999px; background: rgba(255,255,255,.1); font-size: .78rem; }
.training-examples { display: grid; gap: 8px; margin-top: 14px; }
.training-example { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 12px; border-radius: 9px; background: rgba(0,0,0,.16); }
.training-example p { margin: 4px 0; }
.training-mode { display: inline-block; padding: 2px 7px; border-radius: 999px; background: #fff; color: #6200ff; font-size: .68rem; font-weight: bold; text-transform: uppercase; }
.ai-test-row { display: grid; grid-template-columns: 1fr 150px; gap: 12px; }
.ai-test-row > div { display: grid; gap: 9px; align-content: start; }
.ai-test-output { min-height: 70px; margin-top: 12px; padding: 13px; border-left: 4px solid #b9f6ca; border-radius: 8px; background: rgba(0,0,0,.18); white-space: pre-wrap; line-height: 1.5; }

/* ---------- structure assistant + rephraser ---------- */
.structure-card { margin: 10px 0; padding: 13px; border: 1px solid rgba(255,255,255,.15); border-radius: 10px; background: rgba(0,0,0,.16); }
.structure-card p { margin: 5px 0 9px; font-size: .82rem; opacity: .75; }
.structure-preview { padding: 9px; margin-bottom: 9px; border-radius: 7px; background: rgba(255,255,255,.08); font-family: Georgia, serif; font-size: .88rem; line-height: 1.45; }
.rephrase-modes { display: flex; gap: 7px; margin-bottom: 13px; }
.rephrase-label { display: grid; gap: 6px; }
#rephrase-output { width: 100%; min-height: 150px; resize: vertical; border: 1px solid rgba(255,255,255,.22); border-radius: 9px; padding: 12px; background: rgba(0,0,0,.2); color: #fff; line-height: 1.5; }

.paper-wrap {
    position: relative;
    z-index: 1;
    display: flex;
    justify-content: center;
    padding: 30px 16px 80px;
}

.paper {
    --paper-font: 'Times New Roman', Times, serif;
    --title-font: Georgia, 'Times New Roman', serif;
    --body-font: 'Times New Roman', Times, serif;
    --source-font: 'Times New Roman', Times, serif;
    --paper-lh: 2;
    background: #fff;
    color: #111;
    width: 816px;          /* ~8.5in at 96dpi */
    max-width: 100%;
    min-height: 60vh;
    padding: 64px 72px;
    border-radius: 3px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
    animation: pop-in 0.4s ease;
}

/* header block (full mode, MLA/APA/Chicago) */
.header-block {
    margin-bottom: 8px;
    font-family: var(--body-font);
    line-height: var(--paper-lh);
}

.hdr-line {
    display: block;
    width: 100%;
    border: none;
    background: transparent;
    color: #111;
    font-family: var(--body-font);
    font-size: 1.05rem;
    line-height: var(--paper-lh);
    padding: 0;
    margin: 0;
}

.hdr-line:focus { outline: none; background: #fff7d6; }
.hdr-line::placeholder { color: #b0b0b0; }

/* the editable title */
.paper-title {
    width: 100%;
    border: none;
    background: transparent;
    color: #111;
    font-family: var(--title-font);
    font-size: 1.5rem;
    font-weight: bold;
    line-height: 1.4;
    padding: 0;
    margin: 6px 0 14px;
}

.paper-title:focus { outline: none; background: #fff7d6; }

/* the writing area: textarea sits transparently over a highlight backdrop */
.editor-field {
    position: relative;
    width: 100%;
}

.highlights,
.body-input {
    font-family: var(--body-font);
    font-size: 1.05rem;
    line-height: var(--paper-lh);
    width: 100%;
    margin: 0;
    padding: 0;
    border: none;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    word-break: break-word;
    letter-spacing: normal;
}

.highlights {
    position: relative;
    z-index: 0;
    min-height: 48vh;
    color: #111;
    pointer-events: none;
}

.body-input {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: transparent;
    color: transparent;        /* the visible text is the backdrop's */
    caret-color: #111;
    resize: none;
    overflow: hidden;
}

.body-input:focus { outline: none; }
.body-input::placeholder { color: #b0b0b0; }

/* first-line indent — applied to both layers so they stay aligned */
.paper.indent .highlights,
.paper.indent .body-input {
    text-indent: 3em;
}

/* the hotword underline */
.highlights mark {
    background: rgba(255, 210, 80, 0.35);
    border-bottom: 2px dotted #d98c00;
    color: inherit;
    border-radius: 2px;
}

/* works cited / references (full mode) */
.works-cited {
    margin-top: 32px;
    font-family: var(--source-font);
}

.works-cited h2 {
    font-size: 1.2rem;
    text-align: center;
    margin: 0 0 8px;
    font-weight: bold;
}

.wc-input {
    width: 100%;
    min-height: 120px;
    border: none;
    background: transparent;
    color: #111;
    font-family: var(--source-font);
    font-size: 1.05rem;
    line-height: var(--paper-lh);
    resize: vertical;
    padding: 0;
}

.wc-input:focus { outline: none; background: #fff7d6; }
.wc-input::placeholder { color: #b0b0b0; }

/* ---------- the floating vocabulary popup ---------- */
.hot-popup {
    position: fixed;
    z-index: 50;
    min-width: 200px;
    max-width: 260px;
    background: #2a0a55;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
    color: #fff;
    animation: pop-in 0.18s ease;
}

.hp-label { font-size: 0.8rem; opacity: 0.8; margin-bottom: 8px; }

.hp-choices { display: flex; flex-wrap: wrap; gap: 6px; }

.hp-choice {
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.15s, transform 0.15s;
}

.hp-choice:hover {
    background: #fff;
    color: #2a0a55;
    transform: translateY(-1px);
}

.hp-choice.best {
    border-color: #ffd24f;
    background: rgba(255, 210, 79, 0.18);
}

.hp-choice.best::after {
    content: " best fit";
    font-size: 0.68rem;
    opacity: 0.65;
}

.hp-keep {
    display: block;
    width: 100%;
    margin-top: 10px;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.65);
    font-size: 0.78rem;
    cursor: pointer;
    text-decoration: underline;
}

.hp-keep:hover { color: #fff; }

/* ---------- insert bar (tables & images) ---------- */
.insert-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 22px;
    padding-top: 14px;
    border-top: 1px solid #eee;
}

.insert-label {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 0.85rem;
    color: #777;
}

.ins-btn {
    border: 1px solid #ccc;
    background: #f6f4ff;
    color: #4a18c8;
    border-radius: 8px;
    padding: 7px 12px;
    font-size: 0.85rem;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.15s, transform 0.15s;
}

.ins-btn:hover { background: #ece6ff; transform: translateY(-1px); }

/* ---------- figures: tables & photographs/diagrams ---------- */
.figures { margin-top: 4px; }

.fig-item {
    margin: 20px 0;
    padding: 12px;
    border: 1px dashed #d6d0ea;
    border-radius: 10px;
    background: #fbfaff;
}

.fig-bar {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.fig-tool {
    border: 1px solid #d0c9e8;
    background: #fff;
    color: #4a18c8;
    border-radius: 6px;
    padding: 4px 9px;
    font-size: 0.78rem;
    cursor: pointer;
    transition: background 0.15s;
}

.fig-tool:hover { background: #f0ecff; }

.fig-remove { margin-left: auto; color: #c62828; border-color: #f0c4c4; }
.fig-remove:hover { background: #ffecec; }

.fig-item img {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    margin: 0 auto;
}

.fig-table {
    border-collapse: collapse;
    width: 100%;
    font-family: var(--body-font);
    color: #111;
}

.fig-table td {
    border: 1px solid #999;
    padding: 6px 9px;
    min-width: 44px;
    font-size: 1rem;
    vertical-align: top;
}

.fig-table td:focus {
    outline: 2px solid #6200ff;
    outline-offset: -2px;
    background: #fff7d6;
}

.fig-caption {
    display: block;
    width: 100%;
    margin: 10px 0 0;
    border: none;
    border-bottom: 1px solid #e0dcef;
    background: transparent;
    color: #333;
    font-family: var(--source-font);
    font-size: 0.95rem;
    font-style: italic;
    padding: 5px 0;
}

.fig-caption:focus { outline: none; border-bottom-color: #6200ff; }
.fig-caption::placeholder { color: #b0b0b0; font-style: italic; }

/* ---------- share modal ---------- */
.share-link {
    width: 100%;
    margin: 4px 0 16px;
    font-size: 0.85rem;
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: rgba(0, 0, 0, 0.25);
}

.share-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 14px;
}

.share-actions .btn { flex: 1; }

/* ---------- export chooser ---------- */
.export-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 14px;
}

.export-choice { min-height: 86px; }

/* ---------- read-only share view ---------- */
.view-pre { white-space: pre-wrap; }

#view-body { min-height: 0; }

.view-error {
    position: relative;
    z-index: 1;
    text-align: center;
    opacity: 0.85;
    padding: 60px 20px;
    font-size: 1.1rem;
}

/* ---------- small screens ---------- */
@media (max-width: 600px) {
    body { min-height: 100dvh; }
    .container {
        width: 100%;
        max-width: 100vw;
        min-height: 100dvh;
        align-items: flex-start;
        padding: max(12px, env(safe-area-inset-top)) 12px max(18px, env(safe-area-inset-bottom));
        overflow-y: auto;
    }
    .card {
        width: 100%;
        max-width: 380px;
        min-width: 0;
        margin: auto 0;
        padding: 24px 18px 20px;
        border-radius: 15px;
        overflow: hidden;
    }
    .card .logo { font-size: 1.7rem; }
    .card .tagline { margin-bottom: 16px; }
    .card .tabs { margin-bottom: 16px; }
    .form-pane input { font-size: 16px; margin-bottom: 13px; }
    .form-pane label { font-size: .82rem; }
    .legal-links { margin-top: 14px; }
    .paper { padding: 40px 24px; }
    .format-grid { grid-template-columns: 1fr; }
    .topbar { justify-content: center; }
    .export-grid { grid-template-columns: 1fr; max-height: 52vh; overflow: auto; }
    .owner-stats { grid-template-columns: 1fr; }
    .account-row, .owner-panel-head { align-items: stretch; flex-direction: column; }
    .trainer-grid, .ai-test-row { grid-template-columns: 1fr; }
    .training-example { align-items: stretch; flex-direction: column; }
}

.policy-page { max-width: 760px; margin: 0 auto; padding: 70px 24px; line-height: 1.7; position: relative; z-index: 1; }
.policy-page h1 { font-size: 2.4rem; }
.policy-page p { padding: 14px 0; border-bottom: 1px solid rgba(255,255,255,.12); }

/* =====================================================================
   PRINT — show only the white page, as close to the on-screen paper as
   the browser allows. Editing chrome, the vocab strip, and figure tools
   are all stripped out.
   ===================================================================== */
@media print {
    body, .editor-body {
        background: #fff !important;
        color: #000;
    }

    .topbar, .vocab-bar, .insert-bar, .fig-bar, .hot-popup,
    .modal-backdrop, .blob, .no-print {
        display: none !important;
    }

    .paper-wrap { padding: 0; }

    .paper {
        width: 100%;
        max-width: 100%;
        box-shadow: none;
        border-radius: 0;
        padding: 0;
        animation: none;
    }

    /* the visible body text lives in the highlight backdrop; drop the
       transparent textarea so it can't overlap the print */
    .body-input { display: none !important; }
    .highlights { min-height: 0; }
    .highlights mark { background: none; border-bottom: none; }

    .fig-item {
        border: none;
        background: none;
        padding: 0;
        break-inside: avoid;
    }

    .fig-caption { border-bottom: none; }
}
