:root {
  color-scheme: light;
  --ink: #12212b;
  --muted: #667681;
  --line: #dce4e9;
  --soft: #f4f7f9;
  --panel: #ffffff;
  --accent: #176b87;
  --accent-dark: #10546b;
  --accent-soft: #e2f3f7;
  --danger: #bd2c3a;
  --radius: 18px;
  --shadow: 0 12px 35px rgba(18, 33, 43, .08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--panel); color: var(--ink); font-size: 15px; line-height: 1.45; }
a { color: inherit; }
button, input, textarea { font: inherit; }
button, a, label { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
img, video { display: block; max-width: 100%; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; z-index: 100; top: 8px; left: 8px; padding: 10px 14px; transform: translateY(-160%); background: var(--ink); color: white; border-radius: 8px; }
.skip-link:focus { transform: none; }
:focus-visible { outline: 3px solid rgba(23,107,135,.35); outline-offset: 2px; }

.app-shell { display: grid; grid-template-columns: minmax(200px, 260px) minmax(480px, 640px) minmax(250px, 340px); justify-content: center; min-height: 100vh; }
.sidebar { border-right: 1px solid var(--line); }
.sidebar-inner { position: sticky; top: 0; height: 100vh; padding: 18px 26px 14px 18px; display: flex; flex-direction: column; }
.brand { display: inline-flex; align-items: center; gap: 11px; width: fit-content; margin: 0 0 26px 8px; text-decoration: none; font-size: 20px; font-weight: 800; letter-spacing: -.03em; }
.brand-mark, .auth-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px 12px 12px 4px; background: var(--ink); color: white; font: 800 18px/1 Georgia, serif; transform: rotate(-2deg); box-shadow: 3px 3px 0 var(--accent); }
.nav-links { display: flex; flex-direction: column; gap: 7px; }
.nav-links a { display: flex; align-items: center; gap: 17px; min-height: 50px; padding: 10px 14px; border-radius: 999px; text-decoration: none; font-size: 18px; font-weight: 550; width: fit-content; min-width: 154px; }
.nav-links a:hover, .nav-links a[aria-current="page"] { background: var(--soft); }
.nav-icon { width: 24px; text-align: center; font-size: 25px; line-height: 1; }
.nav-links .write-link { justify-content: center; margin-top: 12px; background: var(--accent); color: white; font-weight: 750; box-shadow: 0 5px 18px rgba(23,107,135,.2); }
.nav-links .write-link:hover { background: var(--accent-dark); }
.sidebar-account { margin-top: auto; display: grid; grid-template-columns: 42px 1fr auto; gap: 10px; align-items: center; padding: 10px; border-radius: 14px; }
.sidebar-account { color: inherit; text-decoration: none; }
.sidebar-account:hover { background: var(--soft); }
.sidebar-account div { min-width: 0; }
.sidebar-account strong, .sidebar-account span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-account span { color: var(--muted); font-size: 13px; }
.sidebar-account form { margin: 0; }
.sidebar-logout { margin: 0 10px; text-align: left; }
.sidebar-logout .icon-button { color: var(--muted); font-size: 12px; }
.icon-button { border: 0; background: transparent; cursor: pointer; font-size: 18px; padding: 6px; border-radius: 50%; }
.sign-in-link { margin-top: auto; display: block; padding: 11px 15px; border: 1px solid var(--line); border-radius: 999px; text-align: center; font-weight: 700; text-decoration: none; }
.guest-actions { margin-top: auto; display: grid; gap: 8px; }
.create-account-link { color: var(--accent); text-align: center; font-weight: 700; text-decoration: none; }

.main-column { min-width: 0; border-right: 1px solid var(--line); }
.column-header { position: sticky; z-index: 10; top: 0; min-height: 64px; padding: 10px 18px; display: flex; align-items: center; background: rgba(255,255,255,.9); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.column-header h1 { margin: 0; font-size: 19px; line-height: 1.25; letter-spacing: -.02em; }
.column-header p { margin: 1px 0 0; color: var(--muted); font-size: 12px; }
.back-header { gap: 18px; }
.back-header > a { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; text-decoration: none; font-size: 20px; }
.back-header > a:hover { background: var(--soft); }

.avatar { width: 42px; height: 42px; flex: 0 0 auto; object-fit: cover; border-radius: 50%; background: #d7e8ee; }
.avatar-fallback { display: grid; place-items: center; color: var(--accent-dark); font-weight: 800; font-size: 17px; background: linear-gradient(135deg,#dff4f5,#c4dfe8); }
.avatar-large { width: 78px; height: 78px; font-size: 30px; border: 4px solid white; box-shadow: 0 4px 16px rgba(18,33,43,.12); }

.composer { display: grid; grid-template-columns: 42px 1fr; gap: 12px; padding: 15px 18px 9px; border-bottom: 8px solid var(--soft); }
.composer form { min-width: 0; }
.composer textarea, .editor-card textarea { display: block; width: 100%; min-height: 86px; resize: none; border: 0; outline: 0; padding: 7px 2px 10px; background: transparent; color: var(--ink); font-size: 19px; line-height: 1.45; }
.composer textarea::placeholder { color: #84929a; }
.composer-toolbar { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--line); padding-top: 9px; }
.composer-tools, .publish-tools { display: flex; align-items: center; gap: 7px; }
.attach-button, .format-button { display: grid; place-items: center; width: 34px; height: 34px; margin: 0; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--accent); cursor: pointer; font-size: 18px; }
.format-button:hover, .attach-button:hover { background: var(--accent-soft); }
.format-button.italic { font-family: Georgia,serif; }
.attach-button input, .attach-wide input, .avatar-setting input, .settings-card label.secondary-button input { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; }
.character-count { min-width: 34px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; font-size: 13px; }
.count-warning { color: #a45a00; font-weight: 700; }
.count-over { color: var(--danger); }
.primary-button, .secondary-button { display: inline-flex; justify-content: center; align-items: center; min-height: 38px; padding: 8px 17px; border: 0; border-radius: 999px; background: var(--accent); color: white; text-decoration: none; font-weight: 750; cursor: pointer; }
.primary-button:hover { background: var(--accent-dark); }
.secondary-button { border: 1px solid var(--line); background: white; color: var(--ink); }
.secondary-button:hover { background: var(--soft); }
.format-help { margin: 7px 0 0; color: var(--muted); font-size: 11px; }
.format-help code { color: #465761; }
.attachment-fields { display: grid; gap: 6px; }
.alt-field { display: grid; grid-template-columns: minmax(100px, 1fr) 2fr; gap: 8px; align-items: center; padding: 8px 10px; background: var(--soft); border-radius: 9px; font-size: 12px; }
.alt-field strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alt-field input { min-width: 0; padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px; background: white; }

.post { position: relative; display: grid; grid-template-columns: 42px minmax(0,1fr); gap: 12px; padding: 14px 18px 7px; border-bottom: 1px solid var(--line); transition: background .15s ease; }
.post:hover { background: #fafcfd; }
.post-header { display: flex; align-items: baseline; gap: 5px; min-width: 0; color: var(--muted); font-size: 14px; }
.post-header .author { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); text-decoration: none; }
.post-header .author strong { font-size: 14px; }
.post-header .author span { color: var(--muted); font-weight: 400; }
.timestamp { flex: 0 0 auto; color: var(--muted); text-decoration: none; }
.edited { margin-left: auto; font-size: 11px; }
.post-body { margin-top: 3px; overflow-wrap: anywhere; white-space: normal; font-size: 15.5px; line-height: 1.5; }
.post-body a, .profile-bio a { color: var(--accent); text-underline-offset: 2px; }
.media-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 2px; margin-top: 11px; overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: var(--line); }
.media-count-1 { grid-template-columns: 1fr; }
.media-count-3 .media-item:first-child { grid-row: span 2; }
.media-item { min-width: 0; background: #eaf0f3; }
.media-item img { width: 100%; height: 100%; max-height: 510px; min-height: 170px; object-fit: cover; }
.media-count-1 .media-item img { object-fit: contain; }
.media-item video { width: 100%; max-height: 510px; background: #0e1418; }
.post-actions { display: flex; justify-content: space-between; align-items: center; max-width: 360px; margin-top: 5px; margin-left: -9px; }
.post-actions a, .post-actions button { display: flex; align-items: center; gap: 4px; min-width: 35px; min-height: 35px; justify-content: center; border: 0; border-radius: 50%; background: transparent; color: var(--muted); text-decoration: none; cursor: pointer; }
.post-actions a:hover, .post-actions button:hover { background: var(--accent-soft); color: var(--accent); }
.post-actions form { margin: 0; }
.post-actions form:last-child button:hover { background: #fdebed; color: var(--danger); }
.tombstone { margin: 8px 0 13px; padding: 10px 12px; border: 1px dashed #bdc9cf; border-radius: 9px; color: var(--muted); font-style: italic; }
.thread-children { margin-left: 28px; border-left: 2px solid var(--line); }
.thread-children .post { padding-left: 16px; }
.ancestors > .post::after { content: ""; position: absolute; top: 56px; bottom: -15px; left: 38px; width: 2px; background: var(--line); }
.selected-post > .post { padding-top: 18px; }
.selected-post > .post > .post-main > .post-body { font-size: 19px; line-height: 1.55; margin-top: 10px; }

.right-rail { padding: 18px 20px; }
.profile-card { position: sticky; top: 18px; padding: 22px; border-radius: var(--radius); background: var(--soft); }
.profile-card h2 { margin: 12px 0 0; font-size: 20px; letter-spacing: -.02em; }
.profile-card .handle { margin: 0; color: var(--muted); }
.profile-bio { margin-top: 13px; }
.site-description { margin: 14px 0 0; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); }
.follow-counts { color: var(--muted); font-size: 13px; }
.follow-counts strong { color: var(--ink); }
.suggested-user { display: grid; grid-template-columns: 42px 1fr; gap: 10px; align-items: center; margin: 13px 0; text-decoration: none; }
.suggested-user span, .suggested-user small { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.suggested-user small { color: var(--muted); }
.rail-footer { position: sticky; top: 350px; padding: 15px 10px; color: var(--muted); font-size: 12px; }
.rail-footer span { color: #94a0a7; }

.empty-state, .error-page { padding: 70px 35px; text-align: center; }
.empty-state h2, .error-page h1 { margin: 14px 0 5px; font-size: 24px; }
.empty-state p, .error-page p { max-width: 380px; margin: 0 auto 22px; color: var(--muted); }
.empty-mark { display: grid; place-items: center; width: 68px; height: 68px; margin: auto; border-radius: 22px; background: var(--accent-soft); color: var(--accent); font: 700 28px Georgia,serif; transform: rotate(-3deg); }
.load-more { padding: 20px; text-align: center; }

.auth-page { min-height: 78vh; display: grid; place-items: center; padding: 30px; background: linear-gradient(145deg,#f7fbfc,#fff 55%); }
.auth-card { width: min(390px,100%); padding: 35px; border: 1px solid var(--line); border-radius: 22px; background: white; box-shadow: var(--shadow); }
.auth-mark { margin-bottom: 25px; }
.auth-card h1 { margin: 0; font-size: 29px; letter-spacing: -.035em; }
.auth-card > p { margin: 5px 0 23px; color: var(--muted); }
.auth-card form, .settings-card form { display: grid; gap: 15px; }
.auth-card label, .settings-card label { display: grid; gap: 6px; font-weight: 650; }
.auth-card input, .settings-card input, .settings-card textarea { width: 100%; padding: 11px 12px; border: 1px solid #cbd6dc; border-radius: 9px; background: white; color: var(--ink); }
.auth-card input:focus, .settings-card input:focus, .settings-card textarea:focus { border-color: var(--accent); outline: 3px solid rgba(23,107,135,.13); }
.full-button { width: 100%; margin-top: 5px; }
.form-error, .form-success { margin: 0 0 13px; padding: 11px 13px; border-radius: 9px; background: #fdebed; color: #8c1e2a; font-size: 13px; }
.form-success { background: #e3f6eb; color: #17623b; }
.auth-switch { text-align: center; font-size: 13px; }
.auth-switch a { color: var(--accent); font-weight: 700; }
.auth-card small { color: var(--muted); font-weight: 400; }

.profile-hero { border-bottom: 1px solid var(--line); }
.profile-banner { height: 125px; background: linear-gradient(135deg,#b9dce3,#e4f3f4 60%,#f3e8d7); }
.profile-identity { position: relative; padding: 0 18px 18px; }
.profile-identity > .avatar { margin-top: -42px; width: 88px; height: 88px; }
.profile-identity h1 { margin: 12px 0 0; font-size: 23px; }
.profile-identity .handle { margin: 0; color: var(--muted); }
.profile-identity .profile-bio { margin-top: 12px; }
.profile-actions { position: absolute; top: 10px; right: 18px; display: flex; gap: 8px; }
.profile-actions form { margin: 0; }
.profile-tabs { padding: 14px 18px 0; border-bottom: 1px solid var(--line); font-weight: 750; }
.profile-tabs span { display: inline-block; padding: 0 14px 12px; border-bottom: 3px solid var(--accent); }
.profile-notice { margin: 12px 18px 0; }
.blocked-state { padding: 35px; color: var(--muted); text-align: center; }
.status-pill { padding: 8px 13px; border-radius: 999px; background: var(--soft); color: var(--muted); }
.remote-badge { display: inline-flex; align-items: center; padding: 2px 6px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 10px; font-weight: 750; text-transform: uppercase; letter-spacing: .04em; }
.profile-menu { position: relative; }
.profile-menu > summary { list-style: none; cursor: pointer; }
.profile-menu > summary::-webkit-details-marker, .action-menu > summary::-webkit-details-marker { display: none; }
.profile-menu-panel { position: absolute; z-index: 20; top: 44px; right: 0; width: 250px; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: white; box-shadow: var(--shadow); }
.profile-menu-panel button { width: 100%; padding: 9px; border: 0; background: transparent; text-align: left; cursor: pointer; }
.profile-menu-panel button:hover { background: var(--soft); }
.report-form { display: grid; gap: 7px; padding: 8px; }
.report-form select, .report-form textarea { width: 100%; padding: 7px; border: 1px solid var(--line); border-radius: 7px; }

.action-menu { position: relative; }
.action-menu > summary { display: grid; place-items: center; min-width: 35px; min-height: 35px; border-radius: 50%; color: var(--muted); cursor: pointer; list-style: none; }
.action-menu > form { position: absolute; z-index: 25; right: 0; bottom: 40px; width: 270px; display: grid; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: white; box-shadow: var(--shadow); }
.action-menu label { display: grid; gap: 4px; font-size: 12px; font-weight: 700; }
.action-menu input, .action-menu select, .action-menu textarea { width: 100%; padding: 7px; border: 1px solid var(--line); border-radius: 7px; }
.danger-button { display: inline-flex; justify-content: center; padding: 8px 13px; border: 0; border-radius: 999px; background: var(--danger); color: white; font-weight: 700; cursor: pointer; }

.policy-page { padding: 30px 26px; }
.policy-content { white-space: normal; line-height: 1.7; }
.policy-page h2 { margin-top: 30px; }

.admin-page { min-height: calc(100vh - 64px); padding: 16px; background: var(--soft); }
.admin-card { margin-bottom: 15px; padding: 20px; border: 1px solid var(--line); border-radius: 14px; background: white; }
.admin-card h2 { margin: 0 0 4px; font-size: 19px; }
.admin-card > p { margin: 0 0 15px; color: var(--muted); }
.admin-form { display: grid; gap: 13px; }
.admin-form label { display: grid; gap: 5px; font-weight: 700; }
.admin-form input, .admin-form textarea, .admin-form select, .invite-result input { width: 100%; padding: 10px; border: 1px solid var(--line); border-radius: 8px; }
.admin-form .primary-button { justify-self: start; }
.user-table > article { display: grid; grid-template-columns: 42px minmax(120px,1fr) minmax(180px,1.3fr); gap: 10px; align-items: center; padding: 11px 0; border-top: 1px solid var(--line); }
.user-table > article:first-child { border-top: 0; }
.user-table article div span { display: block; color: var(--muted); font-size: 12px; }
.user-table form { display: flex; gap: 7px; }
.user-table input { min-width: 0; padding: 8px; border: 1px solid var(--line); border-radius: 7px; }
.report-item { padding: 13px 0; border-top: 1px solid var(--line); }
.report-item header { display: flex; justify-content: space-between; gap: 10px; }
.report-item header span, .quiet { color: var(--muted); }
.report-item blockquote { margin: 8px 0; padding: 8px 12px; border-left: 3px solid var(--line); }
.report-item form { display: flex; gap: 8px; }
.report-item input { flex: 1; padding: 8px; border: 1px solid var(--line); border-radius: 7px; }
.report-resolved { opacity: .7; }
.audit-list { max-height: 350px; overflow: auto; font-size: 12px; }
.audit-list p { margin: 0; padding: 7px 0; border-top: 1px solid var(--line); }

.settings-page { padding: 18px; background: var(--soft); min-height: calc(100vh - 64px); }
.settings-card { margin-bottom: 15px; padding: 22px; border: 1px solid var(--line); border-radius: 15px; background: white; }
.settings-card h2 { margin: 0; font-size: 19px; }
.settings-card > p { margin: 3px 0 19px; color: var(--muted); font-size: 13px; }
.settings-card label > span { float: right; color: var(--muted); font-size: 11px; font-weight: 400; }
.settings-card textarea { resize: vertical; }
.settings-card input:disabled { background: var(--soft); color: var(--muted); }
.settings-card .primary-button, .settings-card form > .secondary-button { justify-self: start; }
.avatar-setting { display: flex; align-items: center; gap: 15px; margin-bottom: 4px; }
.remote-follow-list { margin: 18px 0; border-top: 1px solid var(--line); }
.remote-follow-list article { display: grid; grid-template-columns: 42px 1fr; gap: 10px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--line); }
.remote-follow-list span, .remote-follow-list small { display: block; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.remote-follow-list small { margin-top: 2px; }

.editor-card { padding: 18px; }
.editor-card form { display: grid; gap: 15px; }
.editor-card textarea { resize: vertical; padding: 14px; border: 1px solid var(--line); border-radius: 12px; }
.existing-media { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; border: 0; padding: 0; }
.existing-media legend { margin-bottom: 8px; font-weight: 700; }
.existing-media label { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; padding: 8px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.existing-media img { width: 100%; height: 90px; object-fit: cover; border-radius: 6px; }
.editor-actions { display: flex; align-items: center; gap: 12px; }
.editor-actions .character-count { margin-left: auto; }
.text-button { color: var(--muted); font-weight: 650; text-decoration: none; }

@media (max-width: 1040px) {
  .app-shell { grid-template-columns: 86px minmax(480px,640px) minmax(240px,310px); }
  .sidebar-inner { align-items: center; padding-inline: 10px; }
  .brand { margin-left: 0; }
  .brand-name, .nav-links a span:last-child, .sidebar-account div, .sidebar-account form { display: none; }
  .nav-links a { min-width: 52px; width: 52px; justify-content: center; padding: 8px; }
  .nav-links .write-link { min-width: 52px; }
  .sidebar-account { display: block; }
}

@media (max-width: 800px) {
  .app-shell { grid-template-columns: 72px minmax(0,640px); }
  .right-rail { display: none; }
}

@media (max-width: 560px) {
  body { padding-bottom: 62px; }
  .app-shell { display: block; }
  .sidebar { position: fixed; z-index: 30; right: 0; bottom: 0; left: 0; height: 62px; border-top: 1px solid var(--line); border-right: 0; background: rgba(255,255,255,.96); backdrop-filter: blur(12px); }
  .sidebar-inner { position: static; width: 100%; height: 100%; padding: 5px 12px; flex-direction: row; justify-content: space-around; }
  .brand, .sidebar-account, .sidebar-logout, .guest-actions { display: none; }
  .nav-links { width: 100%; flex-direction: row; justify-content: space-around; }
  .nav-links a, .nav-links .write-link { width: 48px; min-width: 48px; min-height: 48px; margin: 0; background: transparent; box-shadow: none; color: var(--ink); }
  .nav-links .write-link { color: var(--accent); }
  .main-column { border-right: 0; }
  .column-header { min-height: 56px; padding-inline: 14px; }
  .composer { grid-template-columns: 34px 1fr; gap: 9px; padding: 13px 12px 8px; }
  .composer-avatar .avatar { width: 34px; height: 34px; }
  .composer textarea { font-size: 17px; }
  .format-help { display: none; }
  .post { grid-template-columns: 38px minmax(0,1fr); gap: 9px; padding: 12px 11px 6px; }
  .post-avatar .avatar { width: 38px; height: 38px; }
  .post-header .author span { display: none; }
  .thread-children { margin-left: 15px; }
  .selected-post > .post > .post-main > .post-body { font-size: 17px; }
  .media-item img { min-height: 125px; }
  .auth-page { min-height: calc(100vh - 62px); padding: 18px; }
  .auth-card { padding: 26px 22px; }
  .settings-page { padding: 10px; }
  .settings-card { padding: 18px 15px; }
  .editor-card { padding: 12px; }
  .editor-actions { flex-wrap: wrap; }
  .editor-actions .character-count { margin-left: 0; }
  .alt-field { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
