:root {
  --canvas: #f4f6f7;
  --surface: #ffffff;
  --surface-muted: #f8fafb;
  --surface-strong: #eef3f4;
  --ink: #1d2830;
  --muted: #60707c;
  --quiet: #87949d;
  --line: #dce3e6;
  --line-strong: #c7d2d7;
  --accent: #087a73;
  --accent-strong: #05645f;
  --accent-soft: #e0f2ef;
  --danger: #b8473e;
  --shadow: 0 10px 28px rgba(31, 45, 54, .08);
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
*[hidden] { display: none !important; }
html { min-height: 100%; background: var(--canvas); }
body { min-width: 320px; min-height: 100vh; margin: 0; color: var(--ink); background: var(--canvas); font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .56; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(8, 122, 115, .24); outline-offset: 2px; }

.shell { width: min(100% - 36px, 1760px); margin: 0 auto; padding: 22px 0 44px; }
.topbar { position: sticky; top: 12px; z-index: 8; display: grid; grid-template-columns: max-content minmax(0, 1fr) max-content; align-items: center; min-height: 64px; gap: 24px; padding: 0 18px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255, 255, 255, .96); box-shadow: 0 5px 18px rgba(31, 45, 54, .07); }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-size: 19px; font-weight: 720; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 29px; height: 29px; border-radius: 7px; color: #fff; background: var(--accent); font-size: 13px; font-weight: 760; }
.workspace-nav { display: flex; align-items: center; justify-self: start; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-muted); }
.nav-button { min-height: 36px; padding: 5px 14px; border: 0; border-radius: 5px; color: var(--muted); background: transparent; font-size: 14px; }
.nav-button:hover { color: var(--ink); background: #edf2f3; }
.nav-button.active { color: var(--ink); background: var(--surface); box-shadow: 0 1px 3px rgba(31, 45, 54, .11); }
.top-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; min-width: 0; }
.account-chip { max-width: 240px; overflow: hidden; padding: 6px 9px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); background: var(--surface-muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }

.icon-button, .secondary-button, .primary-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; border-radius: 6px; text-decoration: none; transition: background .16s ease, border-color .16s ease, color .16s ease, box-shadow .16s ease; }
.icon-button { width: 40px; padding: 0; border: 1px solid var(--line); color: var(--muted); background: var(--surface); font-size: 17px; }
.icon-button:hover { border-color: var(--line-strong); color: var(--ink); background: var(--surface-muted); }
.secondary-button { padding: 8px 13px; border: 1px solid var(--line); color: #33424b; background: var(--surface); font-size: 14px; font-weight: 630; }
.secondary-button:hover { border-color: var(--line-strong); background: var(--surface-muted); }
.primary-button { min-height: 42px; padding: 9px 14px; border: 1px solid var(--accent-strong); color: #fff; background: var(--accent); box-shadow: 0 4px 10px rgba(8, 122, 115, .18); font-weight: 690; }
.primary-button:hover { background: var(--accent-strong); }
.primary-button b { display: grid; place-items: center; width: 18px; height: 18px; border-radius: 4px; background: rgba(255, 255, 255, .16); font-size: 15px; font-weight: 400; line-height: 1; }

.app-main { padding-top: 46px; }
.page-heading, .reader-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 20px; }
.section-label { margin: 0 0 5px; color: var(--accent); font-size: 12px; font-weight: 720; }
.page-heading h1, .reader-head h1 { margin: 0; color: var(--ink); font-size: 40px; line-height: 1.15; font-weight: 730; }
.heading-actions { display: flex; align-items: center; gap: 8px; }
.new-button { min-width: 92px; }
.new-button b { font-size: 18px; font-weight: 400; line-height: 1; }

.work-grid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; align-items: start; gap: 24px; }
.editor-panel, .account-panel, .recent-panel, .reader-view, .result-panel, .settings-panel { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.editor-panel { overflow: hidden; }
.editor-toolbar { display: grid; grid-template-columns: minmax(0, 1fr) 180px max-content; align-items: end; gap: 22px; padding: 22px 26px 18px; border-bottom: 1px solid var(--line); background: var(--surface); }
.field label { display: block; margin-bottom: 5px; color: var(--muted); font-size: 12px; font-weight: 650; }
.field input, .field select { width: 100%; height: 32px; padding: 0; border: 0; color: var(--ink); background: transparent; outline: 0; }
.field input { font-size: 23px; font-weight: 690; }
.field input::placeholder { color: #a6b1b8; }
.field select { color: var(--muted); font-size: 14px; cursor: pointer; }
.preview-toggle { align-self: end; }
.editor-wrap { display: grid; grid-template-columns: 58px minmax(0, 1fr); min-height: 720px; padding: 24px 28px 28px 0; background: var(--surface-muted); }
.line-gutter { overflow: hidden; padding: 1px 18px 0 0; color: #a2afb8; font: 13px/1.9 var(--mono); text-align: right; white-space: pre; user-select: none; }
.editor-wrap textarea { display: block; width: 100%; min-height: 676px; padding: 0; resize: vertical; border: 0; color: #24323a; background: transparent; font: 16px/1.9 var(--mono); outline: 0; tab-size: 2; }
.editor-wrap textarea::placeholder { color: #9aa7b0; }
.editor-foot { display: flex; justify-content: space-between; gap: 14px; padding: 12px 26px; border-top: 1px solid var(--line); color: var(--quiet); background: var(--surface); font-size: 13px; }
.draft-state.saved { color: var(--accent); }
.publish-bar { display: grid; grid-template-columns: minmax(0, 1fr) max-content; align-items: end; gap: 20px; padding: 18px 26px; border-top: 1px solid var(--line); background: var(--surface); }
.publish-options { display: grid; grid-template-columns: minmax(170px, 240px) minmax(0, 1fr); align-items: end; gap: 16px; min-width: 0; }
.inline-field, .search-field { display: grid; gap: 5px; color: var(--muted); font-size: 12px; }
.inline-field input, .search-field input, .compact-form input, .dialog-form input { width: 100%; min-height: 38px; padding: 0 10px; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); background: #fff; }
.inline-field input:focus, .search-field input:focus, .compact-form input:focus, .dialog-form input:focus { border-color: #6eaaa5; outline: 0; }
.expiry-control { display: flex; align-items: center; gap: 10px; min-width: 0; }
.control-label { flex: 0 0 auto; color: var(--muted); font-size: 12px; }
.segmented { display: inline-grid; grid-template-columns: repeat(4, minmax(0, 1fr)); flex: 1 1 auto; min-width: 242px; padding: 3px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-strong); }
.segmented button { min-width: 0; min-height: 30px; padding: 3px 6px; border: 0; border-radius: 5px; color: var(--muted); background: transparent; font-size: 12px; }
.segmented button:hover { color: var(--ink); }
.segmented button.active { color: var(--ink); background: #fff; box-shadow: 0 1px 3px rgba(31, 45, 54, .12); }

.side-rail { display: grid; gap: 14px; }
.account-panel { display: grid; gap: 5px; padding: 21px; background: #f1f8f7; }
.account-panel strong { font-size: 18px; line-height: 1.3; }
.account-panel > span { color: var(--muted); font-size: 13px; }
.status-line { display: flex; align-items: center; gap: 7px; margin-top: 11px; padding-top: 11px; border-top: 1px solid rgba(8, 122, 115, .15); color: #49625f; font-size: 12px; }
.status-line i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.recent-panel { min-height: 320px; padding: 21px 15px 12px; }
.panel-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 0 5px 12px; }
.panel-title .section-label { margin-bottom: 3px; }
.panel-title h2 { margin: 0; font-size: 17px; line-height: 1.25; }
.panel-title > span { padding-top: 2px; color: var(--quiet); font-size: 12px; }
.search-field { margin: 0 5px 10px; }
.search-field span { font-size: 11px; }
.recent-list { display: grid; gap: 2px; }
.recent-empty { margin: 0; padding: 22px 7px 26px; color: var(--quiet); font-size: 13px; }
.recent-item { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 10px; width: 100%; padding: 10px 6px; border: 0; border-radius: 6px; color: inherit; background: transparent; text-align: left; }
.recent-item:hover { background: #f0f6f5; }
.recent-item:focus-visible { outline-offset: -2px; }
.recent-type { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 6px; color: var(--accent-strong); background: var(--accent-soft); font: 12px var(--mono); }
.recent-copy { min-width: 0; }
.recent-copy strong, .recent-copy span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-copy strong { color: #34424b; font-size: 13px; font-weight: 660; }
.recent-copy span { margin-top: 2px; color: var(--quiet); font-size: 11px; }

.result-panel { display: grid; grid-template-columns: 38px minmax(0, 1fr) max-content; align-items: center; gap: 14px; margin-top: 18px; padding: 16px 18px; border-color: #c8e4df; background: #f3fbf9; }
.result-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; color: #fff; background: var(--accent); font-size: 17px; }
.result-copy p, .result-copy h2 { margin: 0; }
.result-copy .section-label { margin-bottom: 2px; }
.result-copy h2 { font-size: 16px; }
.result-copy p:last-child { margin-top: 2px; color: var(--muted); font-size: 12px; }
.result-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 7px; }
.copy-link-button { color: var(--accent-strong); border-color: #a8d5ce; background: #fff; }

.reader-view { overflow: hidden; }
.reader-head { align-items: center; margin: 0; padding: 22px 24px 17px; border-bottom: 1px solid var(--line); }
.reader-head h1 { max-width: 760px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 27px; }
.reader-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 7px; }
.reader-meta { display: flex; flex-wrap: wrap; gap: 7px; padding: 10px 24px; border-bottom: 1px solid var(--line); color: var(--muted); background: var(--surface-muted); font-size: 12px; }
.reader-meta span { padding-right: 8px; border-right: 1px solid var(--line); }
.reader-meta span:last-child { padding-right: 0; border-right: 0; }
.reader-content { min-height: 560px; max-height: 72vh; overflow: auto; margin: 0; padding: 24px; color: #24323a; background: #fff; font: 14px/1.8 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.editor-preview, .reader-preview { min-height: 360px; max-height: 72vh; overflow: auto; padding: 24px; color: var(--ink); background: #fff; line-height: 1.75; }
.editor-preview pre, .reader-preview pre { margin: 0; font: 14px/1.75 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }
.editor-preview h1, .reader-preview h1 { font-size: 26px; }.editor-preview h2, .reader-preview h2 { font-size: 21px; }.editor-preview h3, .reader-preview h3 { font-size: 17px; }
.editor-preview code, .reader-preview code { padding: 1px 4px; border-radius: 3px; background: #eef3f4; font-family: var(--mono); }
.attachment-list { display: grid; gap: 6px; padding: 0 24px 18px; }.attachment-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 0; border-top: 1px solid var(--line); }.attachment-row a { overflow: hidden; color: var(--accent-strong); text-overflow: ellipsis; white-space: nowrap; }.upload-button { cursor: pointer; }

.management-view { max-width: 1280px; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.settings-panel { padding: 21px; }
.settings-panel h2 { margin: 0 0 17px; font-size: 18px; }
.compact-form { display: grid; gap: 12px; }
.compact-form label, .dialog-form > label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 640; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 18px; padding-top: 17px; border-top: 1px solid var(--line); }
.setting-row strong, .setting-row span { display: block; }
.setting-row span { margin-top: 2px; color: var(--muted); font-size: 12px; }
.inline-command { display: flex; align-items: center; gap: 8px; }
.inline-command input { flex: 1; min-width: 0; }
.secret-output { overflow-wrap: anywhere; padding: 10px; border-radius: 6px; color: var(--accent-strong); background: var(--accent-soft); font: 12px/1.5 var(--mono); }
.simple-list { display: grid; gap: 7px; }
.simple-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; padding: 10px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.simple-row:first-child { border-top: 0; padding-top: 0; }
.simple-row > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.admin-stat { padding: 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }.admin-stat strong, .admin-stat span { display: block; }.admin-stat span { color: var(--muted); font-size: 12px; }.admin-stat strong { margin-top: 4px; font-size: 24px; }

.footer { display: flex; justify-content: space-between; gap: 12px; padding-top: 32px; color: var(--quiet); font-size: 12px; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 40; max-width: min(360px, calc(100% - 32px)); padding: 10px 13px; border-radius: 6px; color: #fff; background: #26363d; box-shadow: 0 9px 23px rgba(26, 39, 46, .23); font-size: 13px; opacity: 0; pointer-events: none; transform: translateY(8px); transition: opacity .16s ease, transform .16s ease; }.toast.show { opacity: 1; transform: translateY(0); }

.action-dialog { width: min(100% - 32px, 500px); max-width: 500px; padding: 0; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: var(--surface); box-shadow: 0 24px 60px rgba(31, 45, 54, .2); }.action-dialog::backdrop { background: rgba(25, 36, 42, .42); }.dialog-form { display: grid; gap: 15px; padding: 20px; }.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; }.dialog-head h2 { margin: 0; font-size: 18px; }.dialog-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }.dialog-grid label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 640; }.dialog-grid span { color: var(--quiet); font-size: 11px; }.check-field { display: flex !important; align-items: center; gap: 8px; }.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }.copy-dialog { gap: 14px; }.copy-dialog input { font: 13px/1.5 var(--mono); }

.auth-gate { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 24px; background: rgba(244, 246, 247, .96); }.auth-card { width: min(100%, 480px); overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: #fff; box-shadow: 0 24px 60px rgba(31, 45, 54, .16); }.auth-art { display: none; }.auth-content { padding: 32px; }.auth-brand { font-size: 16px; }.auth-brand .brand-mark { width: 27px; height: 27px; font-size: 12px; }.auth-content > .section-label { margin: 31px 0 6px; }.auth-content h2 { margin: 0; font-size: 30px; line-height: 1.15; }.auth-subtitle { margin: 7px 0 0; color: var(--muted); font-size: 14px; }.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; margin: 23px 0 18px; padding: 3px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-strong); }.auth-tabs button { min-height: 34px; border: 0; border-radius: 5px; color: var(--muted); background: transparent; font-size: 13px; }.auth-tabs button.active { color: var(--ink); background: #fff; box-shadow: 0 1px 3px rgba(31, 45, 54, .11); }.auth-form { display: grid; gap: 13px; }.auth-form label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 640; }.auth-form input { width: 100%; min-height: 43px; padding: 0 11px; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); background: #fff; }.auth-form input:focus { border-color: #6eaaa5; outline: 0; }.auth-submit { width: 100%; margin-top: 3px; }.auth-error { min-height: 18px; margin: 10px 0 0; color: var(--danger); font-size: 12px; }.auth-note { margin: 10px 0 0; color: var(--quiet); font-size: 11px; }

html.dark { --canvas: #182127; --surface: #202c33; --surface-muted: #1b262c; --surface-strong: #29363e; --ink: #edf3f4; --muted: #a6b5bc; --quiet: #83949c; --line: #35444c; --line-strong: #4b5e67; --accent: #28a397; --accent-strong: #48b6a9; --accent-soft: #1e4644; --shadow: 0 12px 30px rgba(0, 0, 0, .25); }
html.dark .topbar, html.dark .account-chip, html.dark .field input, html.dark .field select, html.dark .editor-foot, html.dark .publish-bar, html.dark .reader-content, html.dark .editor-preview, html.dark .reader-preview, html.dark .inline-field input, html.dark .search-field input, html.dark .compact-form input, html.dark .dialog-form input, html.dark .auth-card, html.dark .auth-form input { background: var(--surface); }
html.dark .editor-wrap, html.dark .reader-meta, html.dark .nav-button:hover, html.dark .recent-item:hover { background: var(--surface-muted); }
html.dark .account-panel, html.dark .result-panel { background: #1c3434; }
html.dark .segmented, html.dark .workspace-nav, html.dark .auth-tabs { background: var(--surface-strong); }
html.dark .segmented button.active, html.dark .nav-button.active, html.dark .auth-tabs button.active { background: #33434b; color: var(--ink); }
html.dark .secondary-button, html.dark .icon-button { color: var(--ink); background: var(--surface); }
html.dark .recent-copy strong { color: var(--ink); }
html.dark .auth-gate { background: rgba(24, 33, 39, .97); }

@media (max-width: 1080px) {
  .shell { width: min(100% - 32px, 1160px); }
  .work-grid { grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; }
  .publish-options { grid-template-columns: 1fr; gap: 12px; }
  .inline-field { max-width: 310px; }
}
@media (max-width: 820px) {
  .shell { width: min(100% - 32px, 760px); }
  .topbar { grid-template-columns: max-content 1fr; }.workspace-nav { grid-column: 1 / -1; grid-row: 2; justify-self: stretch; }.workspace-nav .nav-button { flex: 1; }.top-actions { grid-column: 2; grid-row: 1; }
  .app-main { padding-top: 30px; }.work-grid { grid-template-columns: 1fr; }.side-rail { grid-template-columns: 220px minmax(0, 1fr); }.account-panel { min-height: 100%; }.reader-content { min-height: 470px; }.settings-grid { grid-template-columns: 1fr; }.admin-stats { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 610px) {
  .shell { width: min(100% - 24px, 520px); padding-top: 12px; }.topbar { top: 6px; gap: 10px; padding: 8px 10px; }.brand { font-size: 16px; }.top-actions { gap: 6px; }.account-chip { display: none; }.icon-button { width: 34px; min-height: 34px; }.workspace-nav { width: 100%; }.nav-button { min-height: 32px; }
  .page-heading, .reader-head { align-items: flex-start; flex-direction: column; gap: 14px; }.page-heading h1, .reader-head h1 { font-size: 28px; white-space: normal; }.heading-actions { width: 100%; }.heading-actions > * { flex: 1; }.app-main { padding-top: 26px; }.work-grid { gap: 14px; }.editor-toolbar { grid-template-columns: 1fr max-content; gap: 14px; padding: 16px; }.language-field { max-width: 160px; }.title-field { grid-column: 1 / -1; }.editor-wrap { grid-template-columns: 40px minmax(0, 1fr); min-height: 360px; padding: 16px 14px 16px 0; }.line-gutter { padding-right: 10px; }.editor-wrap textarea { min-height: 328px; font-size: 13px; }.editor-foot { padding: 9px 16px; }.publish-bar { grid-template-columns: 1fr; align-items: stretch; padding: 14px 16px; }.inline-field { max-width: none; }.expiry-control { align-items: flex-start; flex-direction: column; gap: 6px; }.segmented { width: 100%; min-width: 0; }.primary-button { width: 100%; }.side-rail { grid-template-columns: 1fr; }.result-panel { grid-template-columns: 34px minmax(0, 1fr); padding: 14px; }.result-actions { grid-column: 1 / -1; justify-content: stretch; }.result-actions > * { flex: 1; }.reader-head { padding: 18px 16px 14px; }.reader-actions { justify-content: flex-start; width: 100%; }.reader-actions .secondary-button { flex: 1; }.reader-meta { padding: 10px 16px; }.reader-content, .editor-preview, .reader-preview { min-height: 410px; padding: 17px; font-size: 13px; }.attachment-list { padding: 0 17px 16px; }.settings-panel { padding: 17px; }.setting-row { align-items: flex-start; flex-direction: column; }.dialog-grid { grid-template-columns: 1fr; }.dialog-actions { flex-wrap: wrap; }.dialog-actions .primary-button { flex: 1; }.footer { padding-top: 25px; }.auth-gate { padding: 16px; }.auth-content { padding: 25px 22px; }.auth-content > .section-label { margin-top: 25px; }.auth-content h2 { font-size: 28px; }.admin-stats { grid-template-columns: 1fr; }
}
