/* Phase 1 phone viewing shell. Loaded from /assets/* so Caddy file-serves it. */

body.is-phone {
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    overscroll-behavior: none;
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    touch-action: manipulation;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body.is-phone #app.is-phone-shell {
    height: 100%;
    height: 100dvh;
}

body.is-phone .topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding: 8px 10px;
    padding-top: max(8px, var(--safe-top));
    padding-left: max(10px, var(--safe-left));
    padding-right: max(10px, var(--safe-right));
    gap: 8px;
    touch-action: manipulation;
}

body.is-phone .mark-word { font-size: 12px; }
body.is-phone .crumbs {
    font-size: 12px;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
body.is-phone .crumbs::-webkit-scrollbar { display: none; }
body.is-phone .crumbs .current,
body.is-phone .crumbs button {
    max-width: 7.5em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

body.is-phone .icon-btn,
body.is-phone .avatar {
    width: 40px;
    height: 40px;
}

body.is-phone .board-titlebar {
    position: fixed;
    top: calc(48px + var(--safe-top));
    left: max(8px, var(--safe-left));
    right: max(8px, var(--safe-right));
    gap: 8px;
    flex-wrap: wrap;
    touch-action: manipulation;
}

body.is-phone .nav-cluster,
body.is-phone .zoom-cluster {
    background: var(--bar);
    border-radius: 999px;
    padding: 2px 4px;
}

body.is-phone .text-btn {
    min-height: 36px;
    padding: 6px 10px;
    font-size: 13px;
}

body.is-phone .hint {
    font-size: 16px;
    top: 58%;
    padding: 0 24px;
    text-align: center;
}

body.is-phone .create-chip { display: none !important; }
body.is-phone .compat-banner { display: none !important; }
body.is-phone:not(.is-arrange) .note .handle,
body.is-phone:not(.is-arrange) .note .move-handle { display: none !important; }

body.is-phone.is-arrange .note .move-handle,
body.is-phone.is-arrange .note .handle.se {
    display: none;
}
body.is-phone.is-arrange .note.is-arrange .move-handle,
body.is-phone.is-arrange .note.is-arrange .handle.se {
    display: grid;
    position: absolute;
    place-items: center;
    place-content: center;
    z-index: 4;
    background: #fffaf0;
    border: 1px solid rgba(42, 36, 24, 0.45);
    box-shadow: var(--shadow);
    touch-action: none;
}
body.is-phone.is-arrange .note.is-arrange .move-handle {
    left: 50%;
    top: -8px;
    width: 72px;
    height: 44px;
    margin-left: -36px;
    border-radius: 12px;
    transform-origin: center bottom;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
}
body.is-phone.is-arrange .note.is-arrange .handle.se {
    right: -8px;
    bottom: -8px;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    transform-origin: center center;
    cursor: nwse-resize;
}
body.is-phone .note-owner {
    font-size: 14px;
    opacity: 0.18;
}
body.is-phone .note-mark,
body.is-phone .note-share,
body.is-phone .note-attach {
    width: 32px;
    height: 32px;
    padding: 4px 5px 0 0;
    opacity: 0.18;
}
body.is-phone .note-mark svg,
body.is-phone .note-share svg,
body.is-phone .note-attach svg {
    width: 14px;
    height: 14px;
}
body.is-phone .note.has-owner .note-caption,
body.is-phone .note.is-image.has-owner .note-caption {
    padding-top: 18px;
}
body.is-phone .note.has-owner textarea.face-edit {
    padding-top: 22px;
}

body.is-phone .view-toolbar {
    display: flex;
    position: fixed;
    left: 50%;
    bottom: max(14px, var(--safe-bottom));
    transform: translateX(-50%);
    z-index: 19;
    gap: 8px;
    pointer-events: none;
    touch-action: manipulation;
}
body.is-phone .view-toolbar .cluster {
    display: none;
    pointer-events: auto;
    background: #fffaf0;
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    border-radius: 999px;
    padding: 4px 6px;
    align-items: center;
    gap: 2px;
}
body.is-phone .view-toolbar .cluster.is-on { display: flex; }
body.is-phone .view-toolbar button {
    background: none;
    border: 0;
    min-height: 40px;
    padding: 6px 14px;
    font-size: 14px;
    border-radius: 999px;
}
body.is-phone .view-toolbar button:hover,
body.is-phone .view-toolbar button:active {
    background: rgba(42, 36, 24, 0.06);
}
body.is-phone .view-toolbar button.is-on {
    background: rgba(42, 36, 24, 0.12);
    font-weight: 600;
}
body.is-phone .view-toolbar .cluster {
    flex-wrap: wrap;
    justify-content: center;
    max-width: calc(100vw - 24px);
}

body.is-phone .toolbar.toolbar-edit { display: none !important; }

body.is-phone .panel,
body.is-phone .sheet {
    position: fixed;
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: 72vh;
    border-left: 0;
    border-top: 1px solid var(--line);
    border-radius: 16px 16px 0 0;
    padding-bottom: var(--safe-bottom);
    touch-action: manipulation;
}

body.is-phone .auth-card {
    position: fixed;
    left: max(12px, var(--safe-left));
    right: max(12px, var(--safe-right));
    bottom: max(16px, var(--safe-bottom));
    transform: none;
    width: auto;
    flex-direction: column;
    align-items: stretch;
    padding: 16px;
    gap: 12px;
    touch-action: manipulation;
}
body.is-phone .auth-card input {
    flex: 1 1 auto;
    width: 100%;
    min-height: 48px;
    font-size: 16px;
    padding: 12px 14px;
}
body.is-phone .auth-card .primary {
    min-height: 48px;
    font-size: 16px;
    width: 100%;
}

body.is-phone .sheet input,
body.is-phone .sheet textarea,
body.is-phone .panel textarea,
body.is-phone .panel input,
body.is-phone .dialog input,
body.is-phone .dialog textarea,
body.is-phone .modal input,
body.is-phone .modal textarea {
    font-size: 16px;
    min-height: 44px;
}

body.is-phone .modal {
    position: fixed;
    inset: 0;
    touch-action: manipulation;
}

body.is-phone .dialog {
    width: min(440px, calc(100% - 20px));
    max-height: min(86vh, 640px);
    overflow: auto;
}

body.is-phone .actions-sheet {
    display: flex;
    flex-direction: column;
    position: fixed;
    left: max(12px, var(--safe-left));
    right: max(12px, var(--safe-right));
    bottom: max(16px, var(--safe-bottom));
    z-index: 36;
    background: #fffaf0;
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    border-radius: 14px;
    padding: 8px;
    gap: 4px;
    touch-action: manipulation;
}

body.is-phone .toast,
body.is-phone .live-hint {
    position: fixed;
    touch-action: manipulation;
}
body.is-phone .actions-sheet button {
    background: none;
    border: 0;
    text-align: left;
    min-height: 48px;
    padding: 12px 14px;
    font-size: 16px;
    border-radius: 10px;
}
body.is-phone .actions-sheet button:active {
    background: rgba(42, 36, 24, 0.06);
}

body.is-phone .panel-image {
    display: block;
    width: 100%;
    max-height: 220px;
    object-fit: contain;
    background: #f3ead0;
    border: 1px solid var(--line);
}

body.is-phone .conflict-banner {
    background: #f7d4c8;
    border: 1px solid rgba(154, 59, 47, 0.25);
    border-radius: 10px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
body.is-phone .conflict-banner .row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

body.is-phone .appear-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
body.is-phone .appear-row .swatch {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    border: 1px solid rgba(42, 36, 24, 0.2);
    padding: 0;
}
body.is-phone .appear-row select {
    min-height: 40px;
    font-size: 16px;
}

body.is-phone .color-sheet {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 6px 4px;
}
body.is-phone .color-sheet .swatch {
    width: 40px;
    height: 40px;
    border-radius: 999px;
    border: 1px solid rgba(42, 36, 24, 0.2);
}

body.is-phone .link-edit-row input {
    flex: 1 1 140px;
}

body.is-phone #inbox.inbox-phone {
    max-height: 82vh;
    z-index: 34;
}
body.is-phone #inbox.inbox-phone .sheet-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-bottom: 12px;
}
body.is-phone .inbox-card {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 14px;
    background: #fffaf0;
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow);
}
body.is-phone .inbox-card .inbox-swatch {
    width: 100%;
    height: 8px;
    margin: 0 0 10px;
    border-radius: 999px;
}
body.is-phone .inbox-card .inbox-preview {
    min-height: 96px;
    font-size: 16px !important;
    border-radius: 8px;
}
body.is-phone .inbox-dest {
    font-size: 15px;
    gap: 6px;
}
body.is-phone .inbox-dest-select {
    width: 100%;
    min-height: 48px;
    font-size: 16px;
    padding: 10px 12px;
}
body.is-phone .inbox-card .inbox-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 12px;
}
body.is-phone .inbox-card .inbox-actions .primary,
body.is-phone .inbox-card .inbox-actions .text-btn {
    min-height: 48px;
    width: 100%;
    font-size: 16px;
}

body.is-phone .people-row {
    min-height: 48px;
    font-size: 15px;
    padding: 8px 0;
    flex-wrap: wrap;
}
body.is-phone .people-row .text-btn {
    min-height: 44px;
    padding: 8px 12px;
}
body.is-phone .people-role {
    min-height: 44px;
    font-size: 16px;
    padding: 8px 10px;
}
body.is-phone .panel-people {
    padding: 8px 0 4px;
}
body.is-phone .attach-row { padding: 12px 0; gap: 8px; }
body.is-phone .attach-thumb {
    width: 48px;
    height: 48px;
}
body.is-phone .attach-actions .text-btn {
    min-height: 44px;
    padding: 10px 12px;
    font-size: 14px;
}
body.is-phone .file-form .text-btn { min-height: 44px; }
body.is-phone .panel #file-form input[type="file"],
body.is-phone .file-form .file-input-hidden {
    display: none !important;
    min-height: 0;
    width: 0;
    height: 0;
    padding: 0;
    margin: 0;
    border: 0;
}
body.is-phone .sheet-actions {
    gap: 12px;
    padding: 34px 0 10px;
}
body.is-phone .sheet-action.icon-btn {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
}
body.is-phone .sheet-action-tip {
    font-size: 13px;
    padding: 6px 12px;
}
body.is-phone .role-line {
    display: flex;
    align-items: center;
    gap: 8px;
}
body.is-phone .role-pill {
    font-size: 12px;
    padding: 4px 10px;
}
body.is-phone .comment,
body.is-phone .activity-row {
    font-size: 15px;
    padding: 10px 0;
}
body.is-phone #comment-form textarea {
    min-height: 72px;
}
body.is-phone #comment-form button {
    min-height: 44px;
}
body.is-phone .share-mode {
    min-height: 64px;
    padding: 12px 14px;
    border-radius: 10px;
}
body.is-phone .share-mode span {
    font-size: 13px;
}
body.is-phone .dialog select,
body.is-phone .modal select {
    min-height: 44px;
    font-size: 16px;
}

body.is-plain.is-phone,
body.is-plain {
    overflow: auto;
    position: static;
}
@media (max-width: 720px) {
    .plain { margin: 20px auto; padding: 0 16px 40px; }
    .plain-head { flex-wrap: wrap; gap: 8px; }
    .mail-list a, .plain a.text-btn, .plain a.primary {
        display: inline-block;
        min-height: 44px;
        padding: 10px 16px;
        font-size: 16px;
    }
    .plain input, .plain textarea, .plain select {
        min-height: 44px;
        font-size: 16px;
    }
}
