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

:root {
    --ios-blue-top: #b8d5ed;
    --ios-blue-mid: #5496ca;
    --ios-blue-bot: #1a5a90;
    --ios-border: #1a4670;
    --btn-blue-top: #62b3f4;
    --btn-blue-bot: #2272c3;
    --btn-red-top: #f47062;
    --btn-red-bot: #c32222;
    --linen: #c5ccd3;
    --surface: #ffffff;
    --card-bg: #fefefe;
    --text: #1a1a1a;
    --text-secondary: #6d6d72;
    --text-tertiary: #8e8e93;
    --border: #b2b2b2;
    --border-light: #d9d9de;
    --separator: #c8c7cc;
    --inset-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.15);
    --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.04);
    --radius: 10px;
    --radius-sm: 6px;
    --font: "Helvetica Neue", Helvetica, Arial, sans-serif;
    --sonya: #e8549a;
    --danya: #34a88e;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
    background-color: var(--linen);
    background-image:
        repeating-linear-gradient(0deg, transparent, transparent 3px, rgba(0, 0, 0, 0.02) 3px, rgba(0, 0, 0, 0.02) 4px),
        repeating-linear-gradient(90deg, transparent, transparent 3px, rgba(0, 0, 0, 0.02) 3px, rgba(0, 0, 0, 0.02) 4px);
}

::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.2); border-radius: 3px; }

/* ── Login ─────────────────────────────────────────────── */

.login-page {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 32px 28px 28px;
    width: 100%;
    max-width: 340px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.8);
    animation: slideUp 0.5s ease;
}

.login-icon {
    text-align: center;
    margin-bottom: 8px;
    opacity: 0.7;
}

.login-card h1 {
    font-size: 22px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 2px;
    color: var(--text);
    text-shadow: 0 1px 0 rgba(255,255,255,0.6);
}

.login-card .subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 24px;
    font-size: 13px;
}

.error-message {
    background: linear-gradient(to bottom, #fbe3e3, #f5c6c6);
    color: #9b1c1c;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 14px;
    border: 1px solid #e3a5a5;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.5);
    text-shadow: 0 1px 0 rgba(255,255,255,0.3);
}

.auth-link {
    text-align: center;
    margin-top: 14px;
    font-size: 13px;
    color: var(--text-secondary);
}

.auth-link a {
    color: var(--ios-blue-mid);
    text-decoration: none;
    font-weight: 600;
}

.auth-link a:hover { text-decoration: underline; }

/* ── iOS Grouped Form ──────────────────────────────────── */

.ios-group {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--separator);
    overflow: hidden;
    margin-bottom: 14px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.ios-row {
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--separator);
    min-height: 44px;
}

.ios-row:last-child {
    border-bottom: none;
}

.ios-row label {
    padding: 10px 0 10px 14px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    min-width: 95px;
    flex-shrink: 0;
    text-shadow: 0 1px 0 rgba(255,255,255,0.5);
}

.ios-row input {
    border: none;
    box-shadow: none;
    padding: 10px 14px 10px 8px;
    flex: 1;
    font-size: 15px;
    font-family: var(--font);
    outline: none;
    background: transparent;
    color: var(--text);
    min-height: 44px;
    min-width: 0;
}

.ios-row input:focus {
    box-shadow: none;
}

.ios-row input::placeholder {
    color: var(--text-tertiary);
}

.ios-group textarea {
    width: 100%;
    border: none;
    box-shadow: none;
    padding: 12px 14px;
    min-height: 120px;
    font-size: 15px;
    font-family: var(--font);
    outline: none;
    resize: vertical;
    line-height: 1.6;
    color: var(--text);
    background: transparent;
}

.ios-group textarea::placeholder {
    color: var(--text-tertiary);
}

.ios-section-header {
    font-size: 13px;
    color: var(--text-secondary);
    text-transform: uppercase;
    padding: 10px 14px 5px;
    letter-spacing: 0.02em;
    text-shadow: 0 1px 0 rgba(255,255,255,0.5);
}

.ios-group-photos {
    padding: 14px;
}

/* ── Buttons ───────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
}

.btn-primary {
    background: linear-gradient(to bottom, var(--btn-blue-top) 0%, #4a9ce0 48%, #3381cc 52%, var(--btn-blue-bot) 100%);
    border: 1px solid #1a5a8e;
    color: white;
    text-shadow: 0 -1px 0 rgba(0,0,0,0.3);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.3), 0 1px 2px rgba(0,0,0,0.2);
}

.btn-login {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    margin-top: 6px;
    border-radius: 8px;
}

.btn-primary:hover {
    background: linear-gradient(to bottom, #72bff5 0%, #5aace8 48%, #4391d4 52%, #2a7ac5 100%);
}

.btn-primary:active {
    background: linear-gradient(to bottom, #3381cc 0%, #2272c3 48%, #1a65b0 52%, #14579e 100%);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
}

.btn-danger {
    background: linear-gradient(to bottom, var(--btn-red-top) 0%, #e04a4a 48%, #cc3333 52%, var(--btn-red-bot) 100%);
    border: 1px solid #8e1a1a;
    color: white;
    text-shadow: 0 -1px 0 rgba(0,0,0,0.3);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.3), 0 1px 2px rgba(0,0,0,0.2);
}

.btn-danger:hover {
    background: linear-gradient(to bottom, #f58072 0%, #e85a5a 48%, #d44343 52%, #c52a2a 100%);
}

.btn-ghost {
    background: linear-gradient(to bottom, #fafafa 0%, #e8e8e8 48%, #d8d8d8 52%, #cecece 100%);
    border: 1px solid #a0a0a0;
    color: var(--text);
    text-shadow: 0 1px 0 rgba(255,255,255,0.6);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.6), 0 1px 2px rgba(0,0,0,0.1);
}

.btn-ghost:hover {
    background: linear-gradient(to bottom, #fff 0%, #f0f0f0 48%, #e0e0e0 52%, #d6d6d6 100%);
}

/* ── Header ────────────────────────────────────────────── */

.header {
    background: linear-gradient(to bottom, var(--ios-blue-top) 0%, #6fa8d6 3%, var(--ios-blue-mid) 50%, #3d7ab8 51%, var(--ios-blue-bot) 100%);
    border-bottom: 1px solid var(--ios-border);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.25), 0 1px 4px rgba(0,0,0,0.3);
    padding: 0 12px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    min-width: 0;
    flex-shrink: 0;
}

.header-logo {
    font-size: 18px;
    font-weight: 700;
    color: white;
    text-shadow: 0 -1px 0 rgba(0,0,0,0.35), 0 1px 0 rgba(255,255,255,0.1);
}

.header-center {
    flex: 1;
    display: flex;
    justify-content: center;
    padding: 0 10px;
    min-width: 0;
}

.header-search {
    position: relative;
    width: 100%;
    max-width: 240px;
}

.header-search input {
    width: 100%;
    padding: 5px 10px 5px 26px;
    border: 1px solid rgba(0,0,0,0.25);
    border-radius: 16px;
    font-size: 13px;
    outline: none;
    font-family: var(--font);
    background: rgba(255,255,255,0.2);
    color: white;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.2);
    transition: all 0.25s;
}

.header-search input::placeholder { color: rgba(255,255,255,0.6); }

.header-search input:focus {
    background: rgba(255,255,255,0.92);
    color: var(--text);
}

.header-search input:focus::placeholder { color: var(--text-tertiary); }

.header-search .search-icon {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255,255,255,0.55);
    pointer-events: none;
    transition: color 0.25s;
}

.header-search:focus-within .search-icon { color: var(--text-tertiary); }

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* ── Online dot ────────────────────────────────────────── */

.online-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: linear-gradient(to bottom, #b0b0b0, #808080);
    border: 1.5px solid #5a5a5a;
    box-shadow: inset 0 1px 1px rgba(255,255,255,0.4), 0 1px 1px rgba(0,0,0,0.15);
    transition: all 0.3s;
    flex-shrink: 0;
}

.online-dot.online {
    background: linear-gradient(to bottom, #90ee7b 0%, #4cd964 50%, #30b83e 100%);
    border-color: #228a2e;
    box-shadow: inset 0 1px 1px rgba(255,255,255,0.45), 0 0 4px rgba(76,217,100,0.5), 0 1px 1px rgba(0,0,0,0.12);
}

/* ── User info / Avatar ────────────────────────────────── */

.user-info {
    display: flex;
    align-items: center;
    gap: 7px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    inset: 0;
}

.user-name {
    font-weight: 600;
    font-size: 13px;
    color: white;
    text-shadow: 0 -1px 0 rgba(0,0,0,0.2);
}

.logout-btn {
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    font-size: 12px;
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: 500;
    border: 1px solid rgba(255,255,255,0.15);
    background: rgba(255,255,255,0.08);
    transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.logout-btn:hover { background: rgba(255,255,255,0.18); color: white; }

/* ── Profile Dropdown ─────────────────────────────────── */

.profile-dropdown {
    position: absolute;
    top: 46px;
    right: 12px;
    background: linear-gradient(to bottom, #ffffff, #f0f0f0);
    border: 1px solid #a0a0a0;
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.25), inset 0 1px 0 rgba(255,255,255,0.8);
    padding: 0;
    width: 240px;
    z-index: 150;
    display: none;
    overflow: hidden;
}

.profile-dropdown.active { display: block; }

.profile-dropdown-header {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    padding: 10px 14px 6px;
    text-shadow: 0 1px 0 rgba(255,255,255,0.5);
    border-bottom: 1px solid #d0d0d0;
    background: linear-gradient(to bottom, #fafafa, #ececec);
}

.profile-dropdown-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 14px;
}

.profile-dropdown-row:first-of-type {
    padding-top: 8px;
}

.profile-dropdown-row:last-of-type {
    padding-bottom: 8px;
}

.profile-dropdown-row label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    flex-shrink: 0;
    min-width: 72px;
    text-shadow: 0 1px 0 rgba(255,255,255,0.5);
}

.profile-dropdown-row input {
    flex: 1;
    min-width: 0;
    border: 1px solid #b0b0b0;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 13px;
    font-family: var(--font);
    background: white;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.12);
    outline: none;
    color: var(--text);
}

.profile-dropdown-row input:focus {
    border-color: var(--ios-blue-mid);
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.12), 0 0 3px rgba(84,150,202,0.35);
}

.profile-dropdown-row input::placeholder {
    color: var(--text-tertiary);
}

.btn-save-name {
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    background: linear-gradient(to bottom, var(--btn-blue-top) 0%, var(--btn-blue-bot) 100%);
    border: 1px solid #1a5a8e;
    color: white;
    text-shadow: 0 -1px 0 rgba(0,0,0,0.3);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.3), 0 1px 2px rgba(0,0,0,0.15);
    flex-shrink: 0;
}

.btn-save-name:hover {
    background: linear-gradient(to bottom, #72bff5, #2a7ac5);
}

.profile-dropdown-actions {
    padding: 8px 14px 10px;
    display: flex;
    justify-content: flex-end;
    border-top: 1px solid #d0d0d0;
}

/* ── Activity bar ──────────────────────────────────────── */

.activity-bar {
    background: linear-gradient(to bottom, #fafafa, #efefef);
    border-bottom: 1px solid var(--separator);
    padding: 5px 14px;
    display: none;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    font-style: italic;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

.activity-bar.visible { display: flex; }

.activity-dots {
    display: flex;
    gap: 3px;
    align-items: center;
}

.activity-dots span {
    width: 5px;
    height: 5px;
    background: var(--text-tertiary);
    border-radius: 50%;
    animation: dotPulse 1.4s ease-in-out infinite;
}

.activity-dots span:nth-child(2) { animation-delay: 0.2s; }
.activity-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotPulse {
    0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
    30% { opacity: 1; transform: scale(1); }
}

/* ── Filter bar ────────────────────────────────────────── */

.filter-bar {
    background: linear-gradient(to bottom, #eaeaea, #d8d8d8);
    border-bottom: 1px solid #b5b5b5;
    padding: 7px 12px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.5), 0 1px 2px rgba(0,0,0,0.06);
}

.filter-scroll {
    display: flex;
    gap: 5px;
    overflow-x: auto;
    scrollbar-width: none;
    align-items: center;
    -webkit-overflow-scrolling: touch;
}

.filter-scroll::-webkit-scrollbar { display: none; }

.filter-pill {
    padding: 3px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
    border: 1px solid rgba(0,0,0,0.15);
    background: linear-gradient(to bottom, #fafafa, #e8e8e8);
    color: var(--text-secondary);
    box-shadow: 0 1px 1px rgba(0,0,0,0.05);
    text-shadow: 0 1px 0 rgba(255,255,255,0.5);
    -webkit-tap-highlight-color: transparent;
}

.filter-pill:hover { background: linear-gradient(to bottom, #fff, #f0f0f0); color: var(--text); }

.filter-pill.active {
    background: linear-gradient(to bottom, var(--btn-blue-top), var(--btn-blue-bot));
    color: white;
    border-color: #1a5a8e;
    text-shadow: 0 -1px 0 rgba(0,0,0,0.3);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.25), 0 1px 2px rgba(0,0,0,0.12);
}

.filter-separator {
    width: 1px;
    height: 18px;
    background: rgba(0,0,0,0.12);
    margin: 0 3px;
    flex-shrink: 0;
}

/* ── Feed ──────────────────────────────────────────────── */

.feed-container {
    padding: 16px 12px 100px;
    overflow-y: auto;
}

.feed {
    max-width: 700px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ── Post Cards (iOS 6 style) ─────────────────────────── */

.bubble-row {
    display: flex;
    animation: fadeIn 0.3s ease;
}

.bubble-row-sent,
.bubble-row-received { flex-direction: row; }

.bubble-avatar { display: none; }

.avatar-small {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
    overflow: hidden;
    position: relative;
    border: 1.5px solid rgba(255,255,255,0.5);
    box-shadow: 0 1px 3px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.2);
}

.avatar-small img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    inset: 0;
}

.bubble {
    width: 100%;
    padding: 14px 16px;
    position: relative;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: opacity 0.12s;
    background: linear-gradient(to bottom, #ffffff 0%, #f6f6f6 100%);
    border: 1px solid #a0a0a0;
    border-radius: 12px;
    box-shadow:
        0 2px 4px rgba(0,0,0,0.15),
        0 1px 0 rgba(0,0,0,0.06),
        inset 0 1px 0 rgba(255,255,255,0.8);
}

.bubble:active { opacity: 0.82; }

.bubble-sent,
.bubble-received {
    background: linear-gradient(to bottom, #ffffff 0%, #f6f6f6 100%);
    border: 1px solid #a0a0a0;
    border-radius: 12px;
    box-shadow:
        0 2px 4px rgba(0,0,0,0.15),
        0 1px 0 rgba(0,0,0,0.06),
        inset 0 1px 0 rgba(255,255,255,0.8);
    color: var(--text);
}

.bubble-sent::after,
.bubble-received::after { display: none; }

/* Post card internals */
.bubble-category {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 9px;
    border-radius: 9px;
    display: inline-block;
    margin-bottom: 5px;
    background: linear-gradient(to bottom, #e8edf4, #d4dbe6);
    color: #4a6a8a;
    border: 1px solid #bcc8d8;
    text-shadow: 0 1px 0 rgba(255,255,255,0.5);
}

.bubble-sent .bubble-category,
.bubble-received .bubble-category {
    background: linear-gradient(to bottom, #e8edf4, #d4dbe6);
    color: #4a6a8a;
    border: 1px solid #bcc8d8;
}

.bubble-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 4px;
    line-height: 1.3;
    color: var(--text);
    text-shadow: 0 1px 0 rgba(255,255,255,0.6);
}

.bubble-sent .bubble-title { text-shadow: 0 1px 0 rgba(255,255,255,0.6); }

.bubble-text {
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 6;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: var(--text-secondary);
}

.bubble-sent .bubble-text { text-shadow: none; color: var(--text-secondary); }
.bubble-received .bubble-text { color: var(--text-secondary); }

.bubble-photos {
    display: flex;
    gap: 6px;
    margin: 10px 0 4px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.bubble-photos::-webkit-scrollbar { display: none; }

.bubble-photo {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid #a0a0a0;
    box-shadow: 0 1px 2px rgba(0,0,0,0.12), inset 0 1px 0 rgba(255,255,255,0.3);
}

.bubble-photo-more {
    width: 80px;
    height: 80px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
    background: linear-gradient(to bottom, #f0f0f0, #e0e0e0);
    color: var(--text-secondary);
    border: 1px solid #bbb;
    text-shadow: 0 1px 0 rgba(255,255,255,0.5);
}

.bubble-sent .bubble-photo-more,
.bubble-received .bubble-photo-more {
    background: linear-gradient(to bottom, #f0f0f0, #e0e0e0);
    color: var(--text-secondary);
}

.bubble-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid #d0d0d0;
}

.bubble-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    flex: 1;
    min-width: 0;
}

.bubble-tag {
    padding: 2px 8px;
    border-radius: 9px;
    font-size: 10px;
    font-weight: 600;
    background: linear-gradient(to bottom, #e8edf4, #d4dbe6);
    color: #4a6a8a;
    border: 1px solid #bcc8d8;
    text-shadow: 0 1px 0 rgba(255,255,255,0.5);
}

.bubble-sent .bubble-tag,
.bubble-received .bubble-tag {
    background: linear-gradient(to bottom, #e8edf4, #d4dbe6);
    color: #4a6a8a;
    border: 1px solid #bcc8d8;
}

.bubble-meta {
    font-size: 11px;
    white-space: nowrap;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--text-tertiary);
    text-shadow: 0 1px 0 rgba(255,255,255,0.5);
}

.bubble-sent .bubble-meta,
.bubble-received .bubble-meta { color: var(--text-tertiary); }

/* Tag used in view modal */
.tag {
    padding: 2px 9px;
    border-radius: 9px;
    font-size: 11px;
    font-weight: 600;
    background: linear-gradient(to bottom, #e8edf4, #d4dbe6);
    color: #4a6a8a;
    border: 1px solid #bcc8d8;
    text-shadow: 0 1px 0 rgba(255,255,255,0.5);
}

/* ── FAB ───────────────────────────────────────────────── */

.fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 50px;
    height: 50px;
    border-radius: 14px;
    background: linear-gradient(to bottom, var(--btn-blue-top) 0%, #4a9ce0 48%, #3381cc 52%, var(--btn-blue-bot) 100%);
    color: white;
    border: 1px solid #1a5a8e;
    font-size: 30px;
    font-weight: 300;
    cursor: pointer;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
    padding: 0 0 2px 0;
    text-shadow: 0 -1px 0 rgba(0,0,0,0.3);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.3), 0 3px 10px rgba(0,0,0,0.25);
    transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.fab:hover {
    background: linear-gradient(to bottom, #72bff5 0%, #5aace8 48%, #4391d4 52%, #2a7ac5 100%);
}

.fab:active {
    background: linear-gradient(to bottom, #3381cc 0%, #2272c3 48%, #1a65b0 52%, #14579e 100%);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
    transform: scale(0.93);
}

/* ── Modal ─────────────────────────────────────────────── */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 200;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 50px 16px 16px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s ease;
}

.modal-overlay.active { opacity: 1; visibility: visible; }

.modal {
    background: #efeff4;
    border-radius: 12px;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.1), 0 10px 40px rgba(0,0,0,0.3);
    transform: translateY(12px) scale(0.97);
    transition: all 0.25s ease;
    overflow: hidden;
}

.modal-overlay.active .modal { transform: translateY(0) scale(1); }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    height: 44px;
    background: linear-gradient(to bottom, var(--ios-blue-top) 0%, #6fa8d6 3%, var(--ios-blue-mid) 50%, #3d7ab8 51%, var(--ios-blue-bot) 100%);
    border-bottom: 1px solid var(--ios-border);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.25);
}

.modal-title {
    font-size: 17px;
    font-weight: 700;
    color: white;
    text-shadow: 0 -1px 0 rgba(0,0,0,0.3);
}

.modal-close {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid rgba(0,0,0,0.2);
    background: rgba(255,255,255,0.15);
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: all 0.15s;
    line-height: 1;
    text-shadow: 0 -1px 0 rgba(0,0,0,0.3);
    -webkit-tap-highlight-color: transparent;
}

.modal-close:hover { background: rgba(255,255,255,0.25); }

.modal-body { padding: 16px 14px; }

.modal-footer {
    padding: 6px 14px 12px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ── Photo Upload ──────────────────────────────────────── */

.photo-upload-area {
    border: 2px dashed var(--separator);
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.photo-upload-area:hover,
.photo-upload-area.dragover {
    border-color: var(--ios-blue-mid);
    background: rgba(84,150,202,0.06);
}

.photo-upload-area .upload-icon { color: var(--text-tertiary); margin-bottom: 4px; }
.photo-upload-area .upload-text { color: var(--text-secondary); font-size: 13px; font-weight: 500; }
.photo-upload-area .upload-hint { color: var(--text-tertiary); font-size: 11px; margin-top: 2px; }

.photo-previews {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 0;
}

.photo-previews:not(:empty) {
    margin-top: 10px;
}

.photo-preview {
    position: relative;
    width: 68px;
    height: 68px;
    border-radius: 7px;
    overflow: hidden;
    border: 1px solid var(--border-light);
    box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

.photo-preview img { width: 100%; height: 100%; object-fit: cover; }

.photo-preview .remove-photo {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(0,0,0,0.6);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.15s;
}

.photo-preview:hover .remove-photo { opacity: 1; }

@media (hover: none) {
    .photo-preview .remove-photo { opacity: 0.8; }
}

/* ── Checklist (iOS 6) ─────────────────────────────────── */

.checklist-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
}

.checklist-text-input {
    flex: 1;
    border: 1px solid #b0b0b0;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 14px;
    font-family: var(--font);
    background: white;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
    outline: none;
    min-width: 0;
}

.checklist-text-input:focus {
    border-color: var(--ios-blue-mid);
}

.checklist-remove {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px solid #c0c0c0;
    background: linear-gradient(to bottom, #f8f8f8, #e0e0e0);
    color: #888;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    line-height: 1;
}

.btn-add-checklist {
    width: 100%;
    margin-top: 6px;
    font-size: 13px;
    padding: 6px;
}

.ios6-checkbox {
    width: 22px;
    height: 22px;
    appearance: none;
    -webkit-appearance: none;
    border: 2px solid #a0a0a0;
    border-radius: 5px;
    background: linear-gradient(to bottom, #fafafa, #e8e8e8);
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.1), 0 1px 0 rgba(255,255,255,0.6);
    cursor: pointer;
    flex-shrink: 0;
    position: relative;
}

.ios6-checkbox:checked {
    background: linear-gradient(to bottom, #6dd56d 0%, #4ab84a 48%, #38a038 52%, #2d8a2d 100%);
    border-color: #228822;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.3), 0 1px 0 rgba(255,255,255,0.6);
}

.ios6-checkbox:checked::after {
    content: "✓";
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
    font-weight: 700;
    text-shadow: 0 -1px 0 rgba(0,0,0,0.2);
}

.ios6-checkbox-display {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border: 2px solid #a0a0a0;
    border-radius: 5px;
    background: linear-gradient(to bottom, #fafafa, #e8e8e8);
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.1), 0 1px 0 rgba(255,255,255,0.6);
    flex-shrink: 0;
    cursor: pointer;
}

.ios6-checkbox-display.checked {
    background: linear-gradient(to bottom, #6dd56d 0%, #4ab84a 48%, #38a038 52%, #2d8a2d 100%);
    border-color: #228822;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.3);
}

.ios6-checkbox-display.checked::after {
    content: "✓";
    color: white;
    font-size: 14px;
    font-weight: 700;
    text-shadow: 0 -1px 0 rgba(0,0,0,0.2);
}

.view-checklist {
    margin-top: 12px;
}

.checklist-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
    cursor: pointer;
    font-size: 15px;
    -webkit-tap-highlight-color: transparent;
}

.checklist-item-done {
    text-decoration: line-through;
    color: var(--text-tertiary);
}

.checklist-progress-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.bubble-progress-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 6px 0 2px;
}

.checklist-progress {
    flex: 1;
    height: 10px;
    border-radius: 5px;
    background: linear-gradient(to bottom, #d8d8d8, #c8c8c8);
    border: 1px solid #a8a8a8;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.15);
    overflow: hidden;
}

.checklist-progress-bar {
    height: 100%;
    border-radius: 4px;
    background: linear-gradient(to bottom, #6dd56d 0%, #4ab84a 48%, #38a038 52%, #2d8a2d 100%);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.3);
    transition: width 0.3s ease;
}

.checklist-progress-text {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    text-shadow: 0 1px 0 rgba(255,255,255,0.5);
}

/* ── Comments ─────────────────────────────────────────── */

.view-comments {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--separator);
}

.comments-header {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 10px;
    text-shadow: 0 1px 0 rgba(255,255,255,0.5);
}

.comments-list {
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 10px;
}

.comments-empty {
    font-size: 13px;
    color: var(--text-tertiary);
    text-align: center;
    padding: 8px;
}

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

.comment:last-child { border-bottom: none; }

.comment-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 3px;
}

.comment-author {
    font-size: 13px;
    font-weight: 600;
}

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

.comment-text {
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-secondary);
    word-break: break-word;
}

.comment-form {
    display: flex;
    gap: 6px;
    align-items: center;
}

.comment-form input {
    flex: 1;
    border: 1px solid #b0b0b0;
    border-radius: 8px;
    padding: 7px 12px;
    font-size: 14px;
    font-family: var(--font);
    background: white;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
    outline: none;
    min-width: 0;
}

.comment-form input:focus {
    border-color: var(--ios-blue-mid);
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.1), 0 0 3px rgba(84,150,202,0.3);
}

.btn-comment {
    padding: 7px 14px;
    font-size: 16px;
    border-radius: 8px;
}

.bubble-comment-count {
    font-size: 10px;
    font-weight: 700;
    background: linear-gradient(to bottom, #e8edf4, #d4dbe6);
    color: #4a6a8a;
    border: 1px solid #bcc8d8;
    padding: 1px 6px;
    border-radius: 8px;
    text-shadow: 0 1px 0 rgba(255,255,255,0.5);
}

.bubble-comment-count::before { content: "💬 "; }

.comment-header-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

.comment-actions {
    display: flex;
    gap: 2px;
}

.comment-action-btn {
    background: none;
    border: none;
    font-size: 11px;
    color: var(--ios-blue-mid);
    cursor: pointer;
    font-family: var(--font);
    padding: 0 3px;
    font-weight: 500;
}

.comment-action-btn:hover { text-decoration: underline; }

.comment-action-del { color: var(--btn-red-bot); }

.comment-edit-row {
    display: flex;
    gap: 6px;
    align-items: center;
}

.comment-edit-input {
    flex: 1;
    border: 1px solid #b0b0b0;
    border-radius: 6px;
    padding: 5px 8px;
    font-size: 13px;
    font-family: var(--font);
    background: white;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);
    outline: none;
    min-width: 0;
}

.comment-edit-input:focus {
    border-color: var(--ios-blue-mid);
}

/* ── Markdown inline styles ───────────────────────────── */

.bubble-text code,
.view-note-content code,
.comment-text code {
    background: rgba(0,0,0,0.06);
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 4px;
    padding: 1px 4px;
    font-size: 0.9em;
    font-family: "SF Mono", Monaco, monospace;
}

.bubble-text a,
.view-note-content a,
.comment-text a {
    color: var(--ios-blue-mid);
    text-decoration: underline;
}

/* ── View Modal ────────────────────────────────────────── */

.view-note-title {
    font-size: 19px;
    font-weight: 700;
    margin-bottom: 6px;
    line-height: 1.3;
}

.view-note-meta {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 14px;
    font-size: 13px;
    color: var(--text-tertiary);
    font-weight: 500;
    flex-wrap: wrap;
}

.view-note-content {
    font-size: 15px;
    line-height: 1.7;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-word;
}

.view-note-photos {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 7px;
    margin-top: 14px;
}

.view-note-photo {
    border-radius: 7px;
    overflow: hidden;
    cursor: pointer;
    aspect-ratio: 1;
    border: 1px solid var(--border-light);
}

.view-note-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.2s;
}

.view-note-photo:hover img { transform: scale(1.05); }

.view-note-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 10px;
}

.view-note-actions {
    display: flex;
    gap: 8px;
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--separator);
}

/* ── Lightbox ──────────────────────────────────────────── */

.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.92);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s ease;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.lightbox.active { opacity: 1; visibility: visible; }

.lightbox img {
    max-width: 94vw;
    max-height: 94vh;
    object-fit: contain;
    border-radius: 4px;
}

/* ── Empty State ───────────────────────────────────────── */

.empty-state {
    text-align: center;
    padding: 50px 16px;
    color: var(--text-secondary);
}

.empty-state .empty-icon { margin-bottom: 10px; opacity: 0.3; color: var(--text-tertiary); }

.empty-state h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 3px;
    color: var(--text);
    text-shadow: 0 1px 0 rgba(255,255,255,0.5);
}

.empty-state p { font-size: 13px; max-width: 260px; margin: 0 auto; }

/* ── Toast ─────────────────────────────────────────────── */

.toast-container {
    position: fixed;
    top: 52px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 250;
    display: flex;
    flex-direction: column;
    gap: 6px;
    pointer-events: none;
    width: max-content;
    max-width: 90vw;
}

.toast {
    background: linear-gradient(to bottom, #fefefe 0%, #f0f0f0 48%, #e6e6e6 52%, #dadada 100%);
    color: var(--text);
    padding: 8px 18px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 3px 12px rgba(0,0,0,0.3), 0 0 0 1px rgba(0,0,0,0.12), inset 0 1px 0 rgba(255,255,255,0.8);
    animation: toastIn 0.3s ease, toastOut 0.3s ease 2.5s forwards;
    white-space: nowrap;
    border: 1px solid #a0a0a0;
    text-shadow: 0 1px 0 rgba(255,255,255,0.6);
}

/* ── Animations ────────────────────────────────────────── */

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

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

@keyframes toastIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut {
    from { opacity: 1; }
    to { opacity: 0; transform: translateY(-10px); }
}

/* ── Responsive ────────────────────────────────────────── */

/* Tablets */
@media (max-width: 768px) {
    .header { padding: 0 10px; }
    .header-search { max-width: 180px; }
    .feed { max-width: 100%; }
    .feed-container { padding: 12px 16px 100px; }
}

/* Large phones */
@media (max-width: 480px) {
    .header-search { max-width: 140px; }
    .header-search input { font-size: 12px; padding: 4px 8px 4px 24px; }
    .user-name { display: none; }
    .feed-container { padding: 10px 8px 90px; }

    .bubble { padding: 12px 14px; }
    .bubble-title { font-size: 15px; }
    .bubble-text { font-size: 13px; }

    .modal-overlay { padding: 0; align-items: flex-end; }
    .modal { border-radius: 12px 12px 0 0; max-width: 100%; max-height: 95vh; max-height: 95dvh; overflow-y: auto; }
    .modal-body { padding: 14px 12px; }
    .modal-footer { padding: 6px 12px 10px; }

    .ios-row label { min-width: 80px; font-size: 13px; padding-left: 12px; }
    .ios-row input { font-size: 14px; padding: 10px 12px 10px 6px; }
    .ios-group textarea { font-size: 14px; padding: 10px 12px; }

    .ios-section-header { padding: 10px 12px 5px; font-size: 12px; }
    .ios-group-photos { padding: 12px; }

    .photo-upload-area { padding: 16px 12px; }
    .photo-upload-area .upload-text { font-size: 12px; }

    .fab { bottom: 16px; right: 16px; width: 46px; height: 46px; font-size: 26px; border-radius: 12px; }

    .filter-bar { padding: 6px 8px; }
    .filter-pill { font-size: 11px; padding: 3px 10px; }

    .profile-dropdown { right: 8px; width: 230px; }
    .profile-dropdown-row { padding: 4px 12px; }
    .profile-dropdown-row:first-of-type { padding-top: 7px; }
    .profile-dropdown-row:last-of-type { padding-bottom: 7px; }
    .profile-dropdown-row label { min-width: 66px; }
    .profile-dropdown-actions { padding: 6px 12px 10px; }
}

/* Small phones (iPhone SE, etc.) */
@media (max-width: 375px) {
    .header-logo { font-size: 16px; }
    .header-search { display: none; }
    .logout-btn { font-size: 11px; padding: 2px 6px; }
    .online-dot { margin-right: 2px; }

    .bubble-photo { width: 56px; height: 56px; }
    .bubble-photo-more { width: 56px; height: 56px; }

    .modal-body { padding: 12px 10px; }
    .modal-footer { padding: 4px 10px 8px; }
    .ios-section-header { padding: 12px 10px 4px; }
    .ios-group-photos { padding: 10px; }
    .photo-upload-area { padding: 14px 10px; }

    .view-note-title { font-size: 17px; }
    .view-note-photos { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); }

    .profile-dropdown { width: 200px; right: 6px; }
}

/* Very small phones */
@media (max-width: 320px) {
    .header { height: 40px; }
    .header-logo { font-size: 15px; }
    .feed-container { padding: 8px 6px 80px; }
    .fab { width: 42px; height: 42px; font-size: 24px; bottom: 12px; right: 12px; }
}

/* Landscape phones */
@media (max-height: 500px) and (orientation: landscape) {
    .modal-overlay { padding: 8px; }
    .modal { max-height: 90vh; }
    .feed-container { padding: 10px 12px 80px; }
}

/* Safe areas (iPhone notch) */
@supports (padding: env(safe-area-inset-bottom)) {
    .fab { bottom: calc(16px + env(safe-area-inset-bottom)); }
    .feed-container { padding-bottom: calc(90px + env(safe-area-inset-bottom)); }
    .modal-overlay { padding-bottom: env(safe-area-inset-bottom); }
}
