/* ============================================================
   PublicNotes — yellow-notepad theme
   ============================================================ */

:root {
    --paper: #feef8e;
    --paper-line: #e6d579;
    --paper-margin: rgba(206, 90, 80, 0.35);
    --bar: #c4c4c4;
    --bar-dark: #a9a9a9;
    --ink: #1f1f1f;
}

* { box-sizing: border-box; }

html { position: relative; min-height: 100%; }

body {
    font-family: Arial, Helvetica, "Liberation Sans", FreeSans, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--ink);
    margin: 0;
    min-height: 100vh;
    /* Brown "desk" gradient the notepad sits on */
    background: linear-gradient(to right, #bb8150 0%, #ac8062 22%, #b98d5e 48%, #b77e57 71%, #a67452 91%) fixed;
    background-size: 100% 100%;
}

a { color: #5c3a1e; }

/* ---------------- Layout container ---------------- */
.mainDiv {
    position: relative;
    width: 98%;
    max-width: 1180px;
    min-width: 320px;
    margin: 0 auto;
    padding-top: 18px;
}

/* Top wordmark */
.brandTop {
    text-align: center;
    padding: 6px 0 14px;
}
.brandTop a { display: inline-block; text-decoration: none; }
.brandTop .wordmark {
    display: block;
    font-size: 54px;
    font-weight: 800;
    line-height: 1;
    color: #2a1c0f;
    letter-spacing: -2px;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.25);
}
.brandTop .whatis {
    display: block;
    margin: 6px auto 0;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .6px;
    color: #3a2a17;
    opacity: .75;
}

/* ---------------- Program area (paper + bar) ---------------- */
.programArea {
    width: 100%;
    margin-bottom: 18px;
}

/* Gray toolbar */
.grayBar {
    height: 64px;
    display: flex;
    align-items: center;
    padding: 0 14px;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
    background: linear-gradient(to bottom, #dadada 0%, #c4c4c4 55%, #b4b4b4 100%);
    border: 1px solid #9c9c9c;
    border-bottom: 0;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}
.grayBar .logo {
    display: block;
    font-size: 32px;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -1.5px;
    color: #2a1c0f;
    text-shadow: 0 1px 0 rgba(255, 255, 255, .5);
}
.grayBar .slogan {
    margin-left: 14px;
    align-self: flex-end;
    margin-bottom: 9px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .4px;
    color: #5c4a33;
    opacity: .75;
    white-space: nowrap;
}

.barMenu {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
}
.barMenu .opt {
    font-size: 13px;
    color: #4a4a4a;
    background: #efefef;
    border: 1px solid #b3b3b3;
    border-radius: 6px;
    height: 34px;
    padding: 0 10px;
}
.barMenu select.opt { cursor: pointer; }
.barMenu .opt-toggle.active {
    background: #fff4c2;
    border-color: #d8b94a;
    color: #6a5210;
}

/* The "short" / create button */
.btnShort {
    height: 38px;
    padding: 0 22px;
    border: 0;
    border-radius: 7px;
    font-weight: 800;
    font-size: 15px;
    letter-spacing: .3px;
    color: #4a3500;
    cursor: pointer;
    background: linear-gradient(to bottom, #ffe45e 0%, #f7c948 100%);
    box-shadow: 0 2px 0 #c79a1e, 0 3px 6px rgba(0, 0, 0, 0.25);
    transition: transform .05s ease, filter .15s ease;
}
.btnShort:hover { filter: brightness(1.05); }
.btnShort:active { transform: translateY(2px); box-shadow: 0 0 0 #c79a1e, 0 2px 4px rgba(0, 0, 0, 0.25); }
.btnShort:disabled { opacity: .65; cursor: default; }

/* Custom URL field */
.customWrap {
    display: inline-flex;
    align-items: center;
    height: 34px;
    border: 1px solid #b3b3b3;
    border-radius: 6px;
    background: #efefef;
    overflow: hidden;
}
.customWrap .pfx {
    padding: 0 6px 0 8px;
    color: #777;
    font-size: 13px;
    border-right: 1px solid #cfcfcf;
    line-height: 32px;
}
.customWrap input {
    border: 0;
    outline: 0;
    height: 32px;
    width: 150px;
    padding: 0 8px;
    background: #fff;
    font-size: 13px;
}

/* Selected-files strip (under the bar) */
.attachRow {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 14px;
    background: rgba(0, 0, 0, 0.07);
    border-left: 1px solid #9c9c9c;
    border-right: 1px solid #9c9c9c;
}
.fileChip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #fffbe6;
    border: 1px solid #d8c97e;
    border-radius: 16px;
    padding: 4px 6px 4px 12px;
    font-size: 12px;
    max-width: 260px;
}
.fileChip .n { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.fileChip .s { color: #8a7a3a; }
.fileChip .x {
    border: 0;
    background: #e6d27a;
    color: #5a4a10;
    width: 18px;
    height: 18px;
    line-height: 16px;
    border-radius: 50%;
    cursor: pointer;
    font-weight: 700;
}
.fileChip .x:hover { background: #d9b94a; }

/* ---------------- Yellow ruled paper ---------------- */
.notesArea {
    background-color: var(--paper);
    border-left: 1px solid #d9c873;
    border-right: 1px solid #d9c873;
    padding: 0;
}
.notesTextArea,
.noteRead {
    display: block;
    width: 100%;
    border: 0;
    outline: 0;
    resize: none;
    background-color: transparent;
    color: var(--ink);
    font-family: "Segoe Print", "Marker Felt", "Comic Sans MS", Geneva, Verdana, sans-serif;
    font-size: 19px;
    line-height: 39px;
    letter-spacing: .4px;
    padding: 6px 18px 18px 64px;
    min-height: 62vh;
    /* horizontal rules + left margin line */
    background-image:
        linear-gradient(to bottom, transparent 38px, var(--paper-line) 39px),
        linear-gradient(to right, transparent 47px, var(--paper-margin) 48px, transparent 49px);
    background-size: 100% 39px, 100% 100%;
    background-repeat: repeat-y, no-repeat;
}
.notesTextArea:focus { box-shadow: none; }

/* Read-only note view: keep line breaks, never inject HTML (XSS-safe) */
.noteRead {
    min-height: 50vh;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* Torn / shadowed paper bottom */
.notesBottom {
    height: 16px;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
    background: var(--paper);
    border: 1px solid #d9c873;
    border-top: 0;
    box-shadow: 0 8px 14px rgba(0, 0, 0, 0.28);
}

/* ---------------- Attachments (reader page) ---------------- */
.filesArea {
    background: #fbf3c0;
    border-left: 1px solid #d9c873;
    border-right: 1px solid #d9c873;
    border-top: 1px dashed #d9c873;
    padding: 16px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 14px;
}
.fileCard {
    background: #fff;
    border: 1px solid #e2d9a8;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}
.fileHead {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: #f4ecbf;
    border-bottom: 1px solid #e7dca6;
    font-size: 12px;
}
.fileHead .fileName { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fileHead .fileSize { color: #8a7a3a; margin-left: auto; white-space: nowrap; }
.fileHead .miniBtn { white-space: nowrap; }
.filePreview {
    padding: 10px;
    text-align: center;
    background: #fafafa;
}
.filePreview img {
    max-width: 100%;
    max-height: 420px;
    border-radius: 6px;
    display: block;
    margin: 0 auto;
}
.filePreview video { max-width: 100%; max-height: 420px; border-radius: 6px; }
.filePreview audio { width: 100%; }
.filePreview .pdfFrame { width: 100%; height: 460px; border: 0; background: #fff; }

/* ---------------- Note meta (reader page) ---------------- */
.noteMeta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    color: #3a2a17;
    font-size: 13px;
    font-weight: 600;
    margin: 0 2px 8px;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.2);
}
.noteMeta .spacer { margin-left: auto; }
.miniBtn {
    height: 30px;
    padding: 0 12px;
    border: 0;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    color: #fff;
    background: #333;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}
.miniBtn.alt { background: #efefef; color: #333; border: 1px solid #b3b3b3; }

/* ---------------- Character pill ---------------- */
.char {
    position: fixed;
    bottom: 18px;
    right: 18px;
    min-width: 96px;
    height: 34px;
    line-height: 34px;
    padding: 0 16px;
    text-align: center;
    color: #fff;
    font-weight: 700;
    border-radius: 18px;
    background: #2b2b2b;
    text-shadow: 0 1px 0 #000;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.45);
    z-index: 60;
}
.char.limit { background: #9c2a2a; }

/* ---------------- Inline form error ---------------- */
.formError {
    margin: 12px 2px 0;
    background: #ffe2e2;
    border: 1px solid #e0a3a3;
    color: #8a1f1f;
    border-radius: 8px;
    padding: 10px 14px;
    font-weight: 600;
}

/* ---------------- Shortened-URL popup ---------------- */
.popOverlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: none;
}
.popBox {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 460px;
    max-width: 92vw;
    z-index: 1001;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
    display: none;
}
.popOverlay.show, .popBox.show { display: block; }

.popHead {
    position: relative;
    background: linear-gradient(to bottom, #8a8a8a, #6f6f6f);
    color: #fff;
    text-align: center;
    padding: 14px;
    font-size: 14px;
    letter-spacing: 1px;
    font-weight: 600;
}
.popHead .closeX {
    position: absolute;
    top: 8px;
    right: 12px;
    width: 26px;
    height: 26px;
    line-height: 24px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.25);
    color: #fff;
    cursor: pointer;
    font-weight: 700;
}
.popBody {
    background: #d6d6d6;
    padding: 26px 22px 30px;
    text-align: center;
}
.shortURL {
    font-family: Courier, "Courier New", Monaco, monospace;
    font-weight: 700;
    font-size: 26px;
    letter-spacing: -1px;
    margin-bottom: 18px;
    word-break: break-all;
}
.shortURL a { color: #000; text-decoration: underline; text-shadow: 0 1px 0 #f3f3f3; }
.shortURL a:hover { color: #1e1e1e; text-decoration: none; }

.popActions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}
.popActions button, .popActions a {
    font-size: 13px;
    font-weight: 700;
    padding: 10px 16px;
    border-radius: 8px;
    border: 0;
    cursor: pointer;
    text-decoration: none;
}
.popActions .copy { background: #2b2b2b; color: #fff; }
.popActions .open { background: #fff; color: #2b2b2b; border: 1px solid #b3b3b3; }

/* ---------------- Footer ---------------- */
.siteFooter {
    text-align: center;
    color: #2a1c0f;
    font-weight: 600;
    text-shadow: 0 0.5px 0 rgba(255, 255, 255, 0.35);
    padding: 8px 0 28px;
    font-size: 13px;
}
.siteFooter a { color: #2a1c0f; text-decoration: underline; padding: 0 5px; }
.siteFooter a:hover { color: #4a0000; }

/* ---------------- Generic message pages ---------------- */
.cardPaper {
    background: var(--paper);
    border: 1px solid #d9c873;
    border-radius: 10px;
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.3);
    padding: 40px 24px;
    text-align: center;
}

/* ============================================================
   Live collaborative editor (reader page is now editable)
   ============================================================ */

/* "N editing" presence pill with a gentle pulsing dot */
.presencePill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #1f7a3d;
    color: #fff;
    font-weight: 700;
    font-size: 12px;
    border-radius: 14px;
    padding: 3px 10px;
}
.presencePill .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #8effb0;
    animation: pnPulse 1.6s infinite;
}
@keyframes pnPulse {
    0%   { box-shadow: 0 0 0 0 rgba(142, 255, 176, 0.6); }
    70%  { box-shadow: 0 0 0 6px rgba(142, 255, 176, 0); }
    100% { box-shadow: 0 0 0 0 rgba(142, 255, 176, 0); }
}

/* Save / connection status text in the meta bar */
.saveStatus { font-size: 12px; font-weight: 700; min-height: 1em; color: #3a2a17; }
.saveStatus.ok { color: #1f7a3d; }
.saveStatus.warn { color: #9c2a2a; }
.saveStatus.remote { color: #1c5fb0; }

/* "Edited 2 minutes ago" — flashes each time it moves */
.editedMeta.touched { animation: pnRenewed 1.4s ease-out 1; }

/* Rolling expiry — flashes when an edit pushes the deadline further out */
.expiryMeta { transition: color .2s ease; }
.expiryMeta.renewed {
    color: #1f7a3d;
    animation: pnRenewed 1.4s ease-out 1;
}
@keyframes pnRenewed {
    0%   { transform: scale(1); }
    18%  { transform: scale(1.06); }
    100% { transform: scale(1); }
}

/* Remove-attachment button */
.miniBtn.danger { background: #8a2020; padding: 0 9px; }
.miniBtn.danger:hover { background: #a52626; }
.miniBtn.danger:disabled { opacity: .5; cursor: default; }

/* Upload progress / attachment errors (reuses the home page's chip strip) */
.fileChip.busy { background: #eef6ff; border-color: #a9c8ea; color: #14487f; }
.fileChip.error { background: #ffe2e2; border-color: #e0a3a3; color: #8a1f1f; }
.fileChip .n { max-width: none; }

/* Drag-and-drop hint */
.dropHint {
    position: fixed;
    inset: 0;
    z-index: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    font-weight: 800;
    color: #fff;
    text-shadow: 0 2px 6px rgba(0, 0, 0, .6);
    background: rgba(31, 122, 61, .35);
    border: 4px dashed rgba(255, 255, 255, .8);
    pointer-events: none;
}

/* Connection / rejection banner */
.collabBanner {
    margin: 12px 2px 0;
    background: #ffe2e2;
    border: 1px solid #e0a3a3;
    color: #8a1f1f;
    border-radius: 8px;
    padding: 10px 14px;
    font-weight: 600;
}

/* ---------------- Responsive ---------------- */
@media (max-width: 760px) {
    .notesTextArea { min-height: 46vh; }
    .filesArea { grid-template-columns: 1fr; }
    .dropHint { font-size: 19px; }
}

@media (max-width: 640px) {
    .brandTop .wordmark { font-size: 44px; }
    .grayBar { flex-wrap: wrap; height: auto; padding: 8px 10px; gap: 8px; }
    .grayBar .slogan { display: none; }
    .barMenu { width: 100%; justify-content: flex-end; }
    .notesTextArea, .noteRead { padding-left: 46px; font-size: 17px; }
    .popBox { width: 94vw; }
}
