:root {
    color-scheme: light;
    --bg: #f5f6fa;
    --surface: #ffffff;
    --surface-soft: #f0f2f8;
    --text: #171925;
    --muted: #74798b;
    --line: #e5e7ef;
    --accent: #6658e8;
    --accent-dark: #5144ca;
    --accent-soft: #eeecff;
    --success: #168a63;
    --danger: #c94a59;
    --shadow: 0 14px 36px rgba(35, 38, 56, .06);
    --sidebar: 82px;
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--bg); color: var(--text); }
body, button, input, select, textarea { font: inherit; }
button, input, select, textarea { color: inherit; }
a { color: inherit; text-decoration: none; }
button, a { -webkit-tap-highlight-color: transparent; }
button { border: 0; }
img, video { max-width: 100%; }

.orientation-gate { display: none; }
.application-shell { min-height: 100vh; }
.eyebrow { margin: 0 0 8px; color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .17em; }
.muted { color: var(--muted); }

.sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 20; width: var(--sidebar); padding: 22px 10px 18px;
    display: flex; flex-direction: column; align-items: center; background: rgba(255,255,255,.94); border-right: 1px solid var(--line);
    backdrop-filter: blur(18px);
}
.brand-mark, .login-brand, .mobile-brand {
    display: inline-flex; align-items: baseline; font-weight: 900; letter-spacing: -.09em;
}
.brand-mark { width: 50px; height: 50px; justify-content: center; border-radius: 15px; color: #fff; background: var(--text); }
.brand-mark span { font-size: 19px; }
.brand-mark small { font-size: 12px; letter-spacing: -.04em; }
.nav-stack { display: flex; flex: 1; flex-direction: column; gap: 8px; justify-content: center; width: 100%; }
.nav-item {
    width: 100%; min-height: 56px; padding: 7px 4px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    color: #8a8d99; background: transparent; border-radius: 14px; cursor: pointer; font-size: 9px; font-weight: 700; transition: .2s ease;
}
.nav-item:hover { color: var(--text); background: var(--surface-soft); }
.nav-item.is-active { color: var(--accent); background: var(--accent-soft); }
.sidebar-logout { width: 100%; }

.main-stage { min-height: 100vh; margin-left: var(--sidebar); padding: 0 3vw 54px; }
.topbar {
    min-height: 130px; padding: 27px 0 22px; display: flex; align-items: center; justify-content: space-between; gap: 30px;
    border-bottom: 1px solid var(--line);
}
.topbar h1 { margin: 0; font-size: clamp(28px, 3vw, 46px); line-height: 1; letter-spacing: -.05em; }
.topbar p:last-child { margin: 9px 0 0; color: var(--muted); font-size: 14px; }
.account-chip { display: inline-flex; align-items: center; gap: 11px; padding: 8px 13px 8px 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; }
.account-chip > span:last-child, .author > span:last-child, .table-user > span:last-child, .person-main > span:last-child { display: flex; flex-direction: column; }
.account-chip strong, .author strong, .table-user strong, .person-main strong { font-size: 13px; }
.account-chip small, .author small, .table-user small, .person-main small { margin-top: 3px; color: var(--muted); font-size: 11px; }

.avatar { flex: 0 0 auto; width: 44px; height: 44px; display: inline-grid; place-items: center; border-radius: 15px; color: var(--accent-dark); background: var(--accent-soft); font-size: 12px; font-weight: 900; letter-spacing: .03em; }
.avatar-small { width: 37px; height: 37px; border-radius: 12px; font-size: 10px; }
.avatar-large { width: 58px; height: 58px; border-radius: 19px; font-size: 15px; }
.avatar-hero { width: 96px; height: 96px; border-radius: 30px; font-size: 24px; }

.flash { margin: 20px 0 0; padding: 14px 17px; border-radius: 13px; font-size: 13px; font-weight: 650; }
.flash-success { color: #106b4e; background: #e8f8f2; border: 1px solid #c4eadc; }
.flash-error { color: #9d3442; background: #fff0f2; border: 1px solid #f3ccd2; }

.content-layout { width: min(1420px, 100%); margin: 24px auto 0; }
.feed-column { display: grid; gap: 18px; }
.feed-wide { width: 100%; }
.panel, .post-card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: none; }
.panel { padding: 25px; }
.panel h2, .empty-state h2, .section-heading h2 { margin: 0; letter-spacing: -.035em; }
.panel > p:not(.eyebrow) { margin: 12px 0 22px; color: var(--muted); font-size: 14px; line-height: 1.65; }
.post-card { display: grid; grid-template-columns: minmax(0, 16fr) minmax(270px, 7fr); overflow: hidden; }
.post-side { min-width: 0; display: flex; flex-direction: column; border-left: 1px solid var(--line); }
.post-header { padding: 20px; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.author { min-width: 0; display: flex; align-items: center; gap: 12px; }
.author small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-frame { width: 100%; align-self: start; aspect-ratio: 16 / 9; overflow: hidden; background: #e9ebf2; }
.media-frame img, .media-frame video { display: block; width: 100%; height: 100%; object-fit: cover; }
.post-content { min-height: 0; padding: 4px 20px 18px; display: flex; flex: 1; flex-direction: column; justify-content: space-between; }
.post-actions { min-height: 34px; margin-top: 18px; display: flex; align-items: center; justify-content: space-between; }
.like-button { display: inline-flex; align-items: center; gap: 8px; padding: 6px 8px 6px 0; background: transparent; cursor: pointer; }
.like-button strong { font-size: 13px; }
.like-button.is-liked { color: var(--danger); }
.like-button.is-liked svg { fill: currentColor; }
.caption { margin: 0; color: #3f4250; font-size: 13px; line-height: 1.6; }
.caption strong { margin-right: 4px; }
.icon-button { padding: 8px; color: var(--muted); background: transparent; border-radius: 10px; cursor: pointer; }
.icon-button:hover { background: var(--surface-soft); }
.icon-button.danger:hover { color: var(--danger); background: #fff0f2; }

.button { min-height: 42px; padding: 10px 17px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 12px; cursor: pointer; font-size: 12px; font-weight: 800; transition: .18s ease; }
.button:hover { transform: translateY(-1px); }
.button-primary { color: #fff; background: var(--accent); box-shadow: 0 9px 18px rgba(102,88,232,.18); }
.button-primary:hover { background: var(--accent-dark); }
.button-quiet { color: var(--text); background: var(--surface-soft); }
.button-danger { color: #a73a48; background: #fff0f2; }
.button-small { min-height: 34px; padding: 7px 11px; font-size: 10px; }
.button-wide { width: 100%; }

label { display: grid; gap: 8px; color: #4c5060; font-size: 11px; font-weight: 800; }
label small { color: var(--muted); font-weight: 500; line-height: 1.4; }
input, select, textarea { width: 100%; padding: 12px 13px; outline: 0; background: #fafbfe; border: 1px solid var(--line); border-radius: 12px; font-size: 13px; transition: border .2s, box-shadow .2s; }
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: #afa8f5; box-shadow: 0 0 0 4px var(--accent-soft); }
.form-stack { display: grid; gap: 17px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 17px; }
.form-grid .button { align-self: end; }

.dashboard-grid { margin-top: 30px; display: grid; grid-template-columns: minmax(300px, .72fr) minmax(520px, 1.28fr); gap: 26px; }
.stats-grid { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stats-grid article { min-height: 145px; padding: 22px; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; }
.stats-grid small { color: var(--muted); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .12em; }
.stats-grid strong { margin: 14px 0 9px; font-size: 34px; letter-spacing: -.05em; }
.stats-grid span { color: var(--muted); font-size: 11px; }
.panel-heading { margin-bottom: 23px; display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.panel-icon { width: 43px; height: 43px; display: grid; place-items: center; color: var(--accent); background: var(--accent-soft); border-radius: 14px; }
.users-panel { min-width: 0; overflow: visible; }
.count-pill, .role-pill { display: inline-flex; padding: 6px 9px; border-radius: 999px; font-size: 10px; font-weight: 800; }
.count-pill { color: var(--muted); background: var(--surface-soft); }
.role-admin { color: #604fcf; background: var(--accent-soft); }
.role-user { color: #4f6076; background: #edf2f7; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 11px; }
th { padding: 11px 10px; color: var(--muted); border-bottom: 1px solid var(--line); text-align: left; font-size: 9px; text-transform: uppercase; letter-spacing: .1em; }
td { padding: 13px 10px; border-bottom: 1px solid #eff0f5; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
.table-user { display: flex; align-items: center; gap: 9px; }
.status-dot { width: 7px; height: 7px; margin-right: 6px; display: inline-block; border-radius: 50%; background: #c5c7d0; }
.status-dot.is-active { background: #24ad7e; box-shadow: 0 0 0 4px #e5f8f1; }
.table-actions { display: flex; gap: 7px; align-items: center; }
details { position: relative; }
summary { list-style: none; }
summary::-webkit-details-marker { display: none; }
.popover-form { position: absolute; z-index: 5; right: 0; top: calc(100% + 8px); width: 245px; padding: 15px; display: grid; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 15px; box-shadow: var(--shadow); }

.search-area { width: min(1100px, 100%); margin: 34px auto 0; }
.search-box { margin-bottom: 26px; padding: 9px 9px 9px 17px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 17px; }
.search-box svg { color: var(--muted); }
.search-box input { padding-left: 0; background: transparent; border: 0; box-shadow: none; font-size: 15px; }
.people-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.person-card { padding: 22px; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; }
.person-main { display: flex; align-items: center; gap: 13px; }
.person-card > p { min-height: 42px; margin: 18px 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.person-stats { margin: auto 0 18px; display: flex; gap: 18px; color: var(--muted); font-size: 10px; }
.person-stats strong { color: var(--text); font-size: 12px; }
.empty-state { min-height: 290px; padding: 45px 25px; display: grid; place-items: center; align-content: center; text-align: center; background: var(--surface); border: 1px dashed #d9dbe5; border-radius: 24px; }
.empty-icon { width: 55px; height: 55px; margin-bottom: 16px; display: grid; place-items: center; color: var(--accent); background: var(--accent-soft); border-radius: 18px; }
.empty-state p { max-width: 410px; margin: 10px auto 0; color: var(--muted); font-size: 13px; line-height: 1.6; }

.profile-hero { margin-top: 30px; display: grid; grid-template-columns: auto minmax(200px, 1fr) auto auto; align-items: center; gap: 25px; }
.profile-copy h2 { margin: 0; font-size: 27px; }
.profile-copy > p:last-child { margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.profile-stats { display: flex; align-items: center; gap: 25px; }
.profile-stats span { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 10px; }
.profile-stats strong { color: var(--text); font-size: 21px; }
.profile-tools { margin-top: 24px; display: grid; grid-template-columns: 1.4fr .6fr; gap: 24px; }
.compose-form { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.compose-form .upload-zone { grid-row: span 2; }
.compose-form > .button { grid-column: 2; justify-self: end; }
.upload-zone { min-height: 190px; padding: 22px; place-items: center; align-content: center; text-align: center; border: 1px dashed #c8c4f1; border-radius: 17px; background: #faf9ff; cursor: pointer; }
.upload-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.upload-zone.is-selected { border-style: solid; background: var(--accent-soft); }
.upload-zone strong { color: var(--text); }
.upload-icon { width: 49px; height: 49px; margin-bottom: 5px; display: grid; place-items: center; color: var(--accent); background: #fff; border-radius: 16px; box-shadow: 0 8px 20px rgba(102,88,232,.12); }
[data-file-name] { max-width: 100%; color: var(--accent); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-feed { margin-top: 42px; }
.section-heading { margin-bottom: 20px; }
.profile-posts { display: grid; grid-template-columns: 1fr; gap: 18px; }

.login-body { overflow: hidden; background: #fff; }
.login-shell { min-height: 100svh; display: grid; grid-template-columns: 1.14fr .86fr; }
.login-visual { position: relative; min-height: 100svh; padding: clamp(34px, 4vw, 68px); display: flex; flex-direction: column; overflow: hidden; color: #fff; background: #1b1c28; }
.login-visual::before { content: ""; position: absolute; width: 63vw; height: 63vw; right: -29vw; bottom: -36vw; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #7c70ed, #574bce 45%, #2a2943 70%); opacity: .86; }
.login-visual::after { content: ""; position: absolute; inset: 0; opacity: .09; background-image: linear-gradient(rgba(255,255,255,.45) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.45) 1px, transparent 1px); background-size: 56px 56px; mask-image: linear-gradient(to bottom right, #000, transparent 65%); }
.login-brand { position: relative; z-index: 1; font-size: 29px; }
.login-brand small { font-size: 17px; }
.visual-copy { position: relative; z-index: 1; width: min(620px, 86%); margin: auto 0; }
.visual-copy .eyebrow { color: #a9a1ff; }
.visual-copy h1 { margin: 0 0 24px; font-size: clamp(42px, 5.3vw, 84px); line-height: .97; letter-spacing: -.065em; }
.visual-copy > p:last-child { max-width: 520px; color: #bbbcc9; font-size: clamp(13px, 1.25vw, 18px); line-height: 1.7; }
.ratio-mark { position: relative; z-index: 1; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 17px; color: #a6a8b8; font-size: 11px; font-weight: 800; }
.ratio-mark i { height: 1px; background: rgba(255,255,255,.2); }
.login-panel { min-height: 100svh; padding: 45px; display: grid; place-items: center; background: #fff; }
.login-card { width: min(390px, 100%); }
.login-card h2 { margin: 0; font-size: clamp(34px, 4vw, 49px); letter-spacing: -.055em; }
.login-card > .muted { margin: 12px 0 27px; font-size: 13px; line-height: 1.6; }
.login-card .flash { margin: 0 0 18px; }
.login-note { margin: 23px 0 0; color: #a0a3af; text-align: center; font-size: 10px; }
.mobile-brand { display: none; }

@media (max-width: 1180px) and (orientation: landscape) {
    :root { --sidebar: 74px; }
    .sidebar { padding-inline: 10px; }
    .nav-item { min-height: 52px; }
    .main-stage { padding-inline: 2.5vw; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .people-grid { grid-template-columns: repeat(2, 1fr); }
    .profile-hero { grid-template-columns: auto 1fr auto; }
    .profile-hero > form { grid-column: 3; }
    .profile-stats { grid-row: 2; grid-column: 2 / 4; }
    .post-card { grid-template-columns: minmax(0, 16fr) minmax(235px, 7fr); }
    .post-header { padding: 15px; }
    .post-content { padding: 2px 15px 14px; }
}

@media (max-height: 560px) and (orientation: landscape) {
    .sidebar { padding-block: 13px; }
    .brand-mark { width: 46px; height: 46px; border-radius: 14px; }
    .nav-stack { gap: 3px; }
    .nav-item { min-height: 48px; gap: 2px; }
    .nav-item span { display: none; }
    .topbar { min-height: 95px; padding-block: 18px; }
    .topbar h1 { font-size: 30px; }
    .account-chip { padding-block: 6px; }
    .content-layout { margin-top: 20px; }
    .visual-copy h1 { font-size: 46px; }
    .login-panel { padding: 25px; }
}

@media (orientation: portrait) and (max-width: 1100px) {
    html, body { width: 100%; height: 100%; overflow: hidden !important; overscroll-behavior: none; }
    #application-shell { display: none !important; }
    #orientation-gate {
        position: fixed; inset: 0; z-index: 99999; padding: 28px; display: grid !important; place-items: center; overflow: hidden;
        background: #f5f6fa;
    }
    .orientation-gate::before { content: ""; position: absolute; width: 380px; height: 380px; right: -210px; bottom: -190px; border-radius: 50%; background: var(--accent-soft); }
    .orientation-card { position: relative; z-index: 1; width: min(420px, 100%); padding: 34px 28px; text-align: center; background: #fff; border: 1px solid var(--line); border-radius: 26px; box-shadow: var(--shadow); }
    .orientation-card h1 { margin: 0; font-size: 31px; letter-spacing: -.05em; }
    .orientation-card > p:not(.eyebrow) { margin: 13px auto 22px; color: var(--muted); font-size: 13px; line-height: 1.6; }
    .phone-turn { width: 82px; height: 58px; margin: 0 auto 24px; display: grid; place-items: center; transform: rotate(-10deg); border: 3px solid var(--accent); border-radius: 13px; animation: turn-phone 1.8s ease-in-out infinite alternate; }
    .phone-turn span { width: 4px; height: 4px; align-self: end; margin-bottom: 3px; border-radius: 50%; background: var(--accent); }
    @keyframes turn-phone { from { transform: rotate(79deg); } to { transform: rotate(-8deg); } }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
