:root {
    --blue: #1d4ed8;
    --blue-dark: #1740c4;
    --bg: #f4f6fb;
    --surface: #ffffff;
    --text: #1b2430;
    --muted: #5b6675;
    --border: #d7dde8;
    --ok: #157347;
    --warn: #a5680a;
    --err: #b42318;
    --kb: 0px; /* on-screen keyboard overlap, set from JS on iOS */
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f141c;
        --surface: #182029;
        --text: #e7ecf3;
        --muted: #9aa6b5;
        --border: #2a3543;
    }
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    overflow: hidden; /* no page scroll — the textarea scrolls instead */
}

body {
    background: var(--bg);
    color: var(--text);
    font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.app {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    min-height: 0;
    max-width: 720px;
    margin: 0 auto;
    padding:
        calc(12px + env(safe-area-inset-top))
        calc(12px + env(safe-area-inset-right))
        calc(12px + env(safe-area-inset-bottom) + var(--kb))
        calc(12px + env(safe-area-inset-left));
    gap: 6px;
}

.bar { flex: 0 0 auto; }

.toprow {
    flex: 0 0 auto;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.photos {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.thumb {
    position: relative;
    width: 72px;
    height: 72px;
    margin: 0;
    border-radius: 12px;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border);
}

.thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.thumb .rm {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 22px;
    height: 22px;
    padding: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    line-height: 22px;
    letter-spacing: 0;
}

.thumb .rm:hover { background: rgba(0, 0, 0, 0.8); }
.thumb .rm:disabled { opacity: 0.4; }

.thumb.add {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-style: dashed;
    color: var(--muted);
    font-size: 30px;
    font-weight: 300;
    line-height: 1;
    user-select: none;
}

.thumb.add:hover {
    border-color: var(--blue);
    color: var(--blue);
}

.thumb.doc {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 6px;
    text-align: center;
}

.thumb.doc .doc-ext {
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.06em;
    color: #c0392b;
}

.thumb.doc .doc-name {
    font-size: 9px;
    line-height: 1.15;
    color: var(--muted);
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    word-break: break-word;
}

textarea {
    flex: 1 1 auto;
    min-height: 0; /* allow it to shrink when the keyboard opens */
    width: 100%;
    resize: none;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    color: inherit;
    font: inherit;
    -webkit-appearance: none;
}

textarea:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.2);
}

.status {
    margin: 0 0 4px;
    min-height: 1.1em;
    font-size: 0.9rem;
    font-weight: 600;
}

.status:empty {
    margin: 0;
    min-height: 0;
}

.status.info { color: var(--muted); }
.status.ok   { color: var(--ok); }
.status.warn { color: var(--warn); }
.status.err  { color: var(--err); }

button {
    width: 100%;
    padding: 16px;
    border: 0;
    border-radius: 14px;
    background: var(--blue);
    color: #fff;
    font: inherit;
    font-weight: 800;
    letter-spacing: 0.03em;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.05s ease;
}

button:hover { background: var(--blue-dark); }
button:active { transform: translateY(1px); }

button:disabled {
    opacity: 0.55;
    cursor: default;
}

.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    margin: -1px; padding: 0; border: 0;
    clip: rect(0 0 0 0);
    overflow: hidden;
}

/* --- Hamburger menu ---------------------------------------------------- */
.menu {
    flex: 0 0 auto;
    position: relative;
}

.menu > summary {
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    color: var(--muted);
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.menu > summary::-webkit-details-marker { display: none; }
.menu > summary:hover,
.menu[open] > summary {
    background: var(--surface);
    color: var(--text);
}

.menu-pop {
    position: absolute;
    right: 0;
    top: 44px;
    z-index: 20;
    min-width: 150px;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
}

.menu-pop a,
.menu-pop button {
    display: block;
    width: 100%;
    margin: 0;
    padding: 10px 12px;
    border: 0;
    border-radius: 8px;
    background: none;
    color: var(--text);
    font: inherit;
    font-size: 0.95rem;
    text-align: left;
    text-decoration: none;
    letter-spacing: 0;
    cursor: pointer;
}

.menu-pop a:hover,
.menu-pop button:hover { background: var(--bg); }

.menu-pop button:disabled { opacity: 0.5; cursor: default; }

/* --- Login screen ------------------------------------------------------- */
.login {
    justify-content: center;
    gap: 14px;
    max-width: 380px;
}

.login h1 {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 800;
    text-align: center;
}

.login-hint {
    margin: 0;
    text-align: center;
    color: var(--muted);
    font-size: 0.9rem;
}

.login input[type="password"] {
    width: 100%;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    color: inherit;
    font: inherit;
    -webkit-appearance: none;
}

.login input[type="password"]:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.2);
}

.remember {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: var(--muted);
}

.remember input {
    width: 18px;
    height: 18px;
}
