:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei UI", "Noto Sans CJK SC", sans-serif;
  color: #142441;
  background: #f3f6fc;
  --primary: #1555ce;
  --primary-dark: #1048b1;
  --primary-soft: #e8f0ff;
  --muted: #52627a;
  --line: #e1e8f4;
  --surface: #fff;
  --danger: #a42538;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100dvh; isolation: isolate; }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
h1, h2, p { margin: 0; }
h2 { font-size: 1.125rem; font-weight: 680; }
.symbols { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 1.25rem; height: 1.25rem; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-inner {
  max-width: 1112px;
  min-height: 72px;
  padding: 10px 24px;
  margin-inline: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 0; font-size: 1.0625rem; font-weight: 730; white-space: nowrap; }
.brand > span:last-child { overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 5px; }
.brand-icon, .gate-icon, .tile-icon, .item-icon {
  display: grid;
  flex: none;
  place-items: center;
  color: var(--primary);
  background: var(--primary-soft);
}
.brand-icon { width: 38px; height: 38px; border-radius: 12px; }
.brand-icon .icon { width: 22px; height: 22px; }

.workspace { max-width: 1112px; margin: 0 auto; padding: 43px 24px 56px; }
.workspace-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 25px; }
.workspace h1 { font-size: clamp(1.85rem, 4vw, 2.35rem); letter-spacing: -.035em; font-weight: 730; overflow-wrap: anywhere; }
.space-wallpaper { position: fixed; inset: 0; z-index: -1; width: 100%; height: 100%; object-fit: cover; opacity: .65; pointer-events: none; }
body:has(.space-wallpaper:not([hidden])) .workspace-heading h1,
body:has(.space-wallpaper:not([hidden])) .history-heading { background: #f3f6fce8; border-radius: 12px; padding-inline: 12px; }
.workspace-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; align-items: start; }
.card { border-radius: 22px; background: var(--surface); border: 1px solid var(--line); box-shadow: 0 2px 5px #24446e08; }
.composer { padding: 24px; min-width: 0; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.composer .section-heading { margin-bottom: 18px; }
.segmented { display: flex; gap: 2px; flex: none; padding: 3px; background: #f1f5fb; border: 1px solid #e8edf6; border-radius: 13px; }
.segmented button { border: 0; border-radius: 9px; padding: 6px 12px; min-height: 32px; background: transparent; color: var(--muted); font-size: .875rem; white-space: nowrap; }
.segmented button[aria-pressed="true"] { color: #174da8; background: #dfeaff; font-weight: 650; }

.button, .icon-button { border: 0; display: inline-flex; align-items: center; justify-content: center; flex: none; background: transparent; color: var(--primary); }
.button { gap: 8px; text-decoration: none; padding: 0 17px; min-height: 42px; border-radius: 100px; font-weight: 650; font-size: .9375rem; white-space: nowrap; }
.button .icon { width: 1.125rem; height: 1.125rem; }
.primary { color: #fff; background: var(--primary); }
.primary:hover { background: var(--primary-dark); box-shadow: 0 2px 8px #1649ae2a; }
.primary:disabled { color: #52617a; background: #e6ebf4; box-shadow: none; }
.tonal { color: #174da8; background: var(--primary-soft); }
.tonal:hover, .text-button:hover, .icon-button:hover { background: #dbe8ff; }
.danger { color: #fff; background: var(--danger); }
.danger:hover { background: #87182a; }
.icon-button { width: 38px; height: 38px; border-radius: 50%; }
.icon-button:disabled { opacity: .45; }

.editor-box { background: #fcfdff; border: 1px solid #dbe4f3; border-radius: 15px; overflow: hidden; }
.editor-box:focus-within { border-color: #7096e5; box-shadow: 0 0 0 1px #7096e5; }
.formatting { display: flex; align-items: center; gap: 3px; min-height: 49px; padding: 4px 9px; border-bottom: 1px solid var(--line); background: #f6f8fd; }
.formatting .icon-button { color: #3b506c; width: 34px; height: 34px; border-radius: 8px; }
.formatting .icon-button[aria-pressed="true"] { color: var(--primary); background: #e3edff; }
.format-bold { font-weight: 800; }
.format-italic { font-family: Georgia, serif; font-weight: 700; font-style: italic; font-size: 1.15rem; }
.format-underline { text-decoration: underline; font-weight: 650; }
.toolbar-divider { height: 22px; width: 1px; background: #dee7f5; margin-inline: 4px; }
.editor { width: 100%; display: block; padding: 15px 17px; min-height: 185px; max-height: 460px; overflow: auto; font-size: 1rem; line-height: 1.65; overflow-wrap: anywhere; outline: 0; }
.editor:empty::before { content: attr(data-placeholder); color: var(--muted); pointer-events: none; }
.markdown-editor { resize: vertical; background: transparent; border: 0; color: inherit; font-family: ui-monospace, Consolas, monospace; }
.markdown-editor::placeholder { color: var(--muted); opacity: 1; }
.composer-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.editor-buttons { display: flex; align-items: center; gap: 5px; margin-inline-start: auto; }
.legacy-notes { max-width: 100%; margin-top: 12px; }
.retention-label { display: flex; align-items: center; gap: 6px; font-size: .875rem; font-weight: 550; color: var(--muted); white-space: nowrap; }
.retention-label .icon { width: 17px; height: 17px; }
.select {
  color: #304660;
  border: 1px solid #dce5f4;
  border-radius: 11px;
  appearance: none;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23465c79' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E") no-repeat right 8px center;
  padding: 8px 32px 8px 11px;
  min-height: 40px;
  font-size: .875rem;
}

.side-panel { display: grid; gap: 16px; }
.side-card { padding: 19px; }
.side-card h2 { font-size: 1rem; margin-bottom: 13px; }
.side-card h2 .icon { color: var(--primary); }
.dropzone { min-height: 166px; border-radius: 16px; border: 1px dashed #a8bfeb; background: #f8faff; display: grid; place-items: center; align-content: center; gap: 9px; padding: 12px; text-align: center; }
.dropzone.active { border-color: var(--primary); border-style: solid; background: #eaf2ff; }
.dropzone p { color: var(--muted); font-size: .875rem; }
.dropzone .button { min-height: 36px; font-size: .875rem; }
.tile-icon, .item-icon { width: 42px; height: 42px; border-radius: 12px; }
.quota h2 { display: flex; align-items: center; gap: 9px; }
.upload-progress { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px; margin-top: 12px; color: var(--muted); font-size: .875rem; font-variant-numeric: tabular-nums; }
:is(.quota, .upload-progress) progress { display: block; width: 100%; height: 8px; appearance: none; border: 0; border-radius: 99px; background: #e7eefb; overflow: hidden; accent-color: var(--primary); }
:is(.quota, .upload-progress) progress::-webkit-progress-bar { background: #e7eefb; }
:is(.quota, .upload-progress) progress::-webkit-progress-value { background: var(--primary); border-radius: 99px; }
:is(.quota, .upload-progress) progress::-moz-progress-bar { background: var(--primary); border-radius: 99px; }
.quota-numbers { display: flex; justify-content: space-between; margin-top: 9px; color: var(--muted); font-size: .875rem; font-variant-numeric: tabular-nums; }

.history { grid-column: 1 / -1; min-width: 0; }
.history-heading { margin-bottom: 10px; padding-inline: 3px; }
.item-list { overflow: hidden; }
.empty { padding: 30px 18px; text-align: center; color: var(--muted); font-size: .9375rem; }
.item-row { display: flex; align-items: center; gap: 12px; padding: 10px 16px; min-height: 68px; }
.item-row + .item-row { border-top: 1px solid var(--line); }
.item-main { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; text-align: start; border: 0; background: transparent; padding: 4px; color: inherit; border-radius: 12px; }
.item-main:hover .item-title { color: var(--primary); }
.item-text { display: grid; gap: 4px; min-width: 0; }
.item-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: .9375rem; font-weight: 650; }
.item-meta { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); font-size: .8125rem; }
.item-actions { display: flex; gap: 3px; }
.item-actions .icon-button { color: #435a7c; }
.more-files { display: flex; width: fit-content; margin: 12px auto 0; }

.dialog { color: inherit; border: 1px solid #e2eafb; border-radius: 26px; width: min(440px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 27px; background: var(--surface); box-shadow: 0 24px 64px #16326935; overscroll-behavior: contain; }
.dialog::backdrop { background: #1b376163; backdrop-filter: blur(3px); }
.gate { width: min(434px, calc(100vw - 32px)); padding: 27px 32px 19px; }
.gate::backdrop { background: #1b37616b; backdrop-filter: blur(5px); }
.gate-heading { display: flex; flex-direction: column; align-items: center; gap: 13px; margin-bottom: 23px; }
.gate-heading h2 { font-size: 1.45rem; letter-spacing: -.025em; }
.gate-icon { width: 54px; height: 54px; border-radius: 17px; }
.gate-icon .icon { width: 25px; height: 25px; }
.field { display: grid; gap: 6px; margin-bottom: 13px; }
.field label { color: #344969; font-size: .875rem; font-weight: 650; }
.field input, .input-with-actions { border: 1px solid #bdcce2; border-radius: 12px; min-height: 49px; color: inherit; background: #fbfdff; }
.field input { width: 100%; padding: 10px 12px; }
.input-with-actions { display: flex; align-items: center; padding-right: 4px; }
.input-with-actions:focus-within, .field > input:focus { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); outline: none; }
.input-with-actions input { background: none; border: 0; outline: none; min-height: 47px; min-width: 0; }
.verification { display: flex; justify-content: center; min-height: 0; margin: 3px 0 12px; }
.verification:empty { margin-bottom: 0; }
.form-error { color: var(--danger); font-size: .875rem; line-height: 1.45; margin: 0 0 11px; overflow-wrap: anywhere; }
.gate-submit { width: 100%; min-height: 46px; }
.gate-switch { display: flex; width: fit-content; margin: 8px auto 0; min-height: 39px; }
.gate-switch .icon { width: 17px; height: 17px; }

.preview-dialog { width: min(760px, calc(100vw - 32px)); }
.dialog-heading { display: flex; justify-content: space-between; align-items: start; gap: 10px; }
.dialog-heading h2 { padding-block: 7px; overflow-wrap: anywhere; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.dialog-actions:empty { display: none; }
.item-dialog h2 { margin-bottom: 17px; }
.settings-dialog { width: min(520px, calc(100vw - 32px)); }
.settings-section { display: grid; gap: 9px; margin: 14px 0 18px; }
.settings-section h3 { margin: 0; color: #344969; font-size: .875rem; font-weight: 650; }
.settings-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.settings-actions input:not([type="file"]) { flex: 1; min-width: 0; width: auto; }
.visits { display: grid; padding: 0; margin: 0; list-style: none; max-height: 215px; overflow: auto; }
.visits li { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 4px 12px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: .875rem; color: var(--muted); }
.visits li:last-child { border-bottom: 0; }
.visit-address { color: #263c58; overflow-wrap: anywhere; }
.visit-location { flex: 1; }
#delete-space h2 { margin-bottom: 14px; }
#delete-space .dialog-actions { flex-wrap: wrap; }
.preview-content { margin-top: 10px; max-height: 67dvh; overflow: auto; overflow-wrap: anywhere; }
.preview-content > img, .preview-content > video { display: block; max-width: 100%; max-height: 58dvh; object-fit: contain; margin-inline: auto; border-radius: 10px; }
.preview-content > audio { display: block; width: min(100%, 520px); margin: 10px auto; }
.prose { line-height: 1.65; }
.prose p { margin: 0 0 .55em; }
.prose p:last-child { margin: 0; }
.prose h1, .prose h2, .prose h3, .prose h4, .prose h5, .prose h6 { margin: .5em 0; line-height: 1.3; }
.prose a { color: var(--primary); }
.prose pre { padding: 12px; background: #edf2fc; border-radius: 8px; white-space: pre-wrap; }
.prose blockquote { border-inline-start: 3px solid #a8bfee; color: #3e5571; margin: .7em 0; padding-inline-start: 14px; }
.prose table { border-collapse: collapse; }
.prose :is(th, td) { border: 1px solid #dce5f1; padding: .3em .6em; }
.markdown-output h1 { font-size: 1.7rem; }
.markdown-output pre { overflow-x: auto; white-space: pre; overflow-wrap: normal; }
.markdown-output :not(pre) > code { background: #edf2fc; border-radius: 4px; padding: .12em .3em; }
.markdown-output code { font-family: ui-monospace, Consolas, monospace; }
.markdown-output hr { border: 0; border-top: 1px solid var(--line); margin-block: 1em; }
.toast { position: fixed; z-index: 5; inset: auto 16px 20px; width: fit-content; max-width: calc(100vw - 32px); margin-inline: auto; background: #193052; color: white; border-radius: 12px; padding: 11px 16px; font-size: .9375rem; box-shadow: 0 6px 20px #18294939; overflow-wrap: anywhere; }

@media (min-width: 1280px) {
  .topbar-inner, .workspace { max-width: clamp(1112px, 78vw, 1520px); }
  .workspace-heading { margin-bottom: clamp(25px, 2vw, 34px); }
  .workspace-grid {
    grid-template-columns: minmax(0, 1fr) clamp(310px, 21vw, 384px);
    gap: clamp(28px, 2vw, 36px);
  }
  .composer {
    --editor-height: clamp(196px, 25vh, 270px);
    padding: clamp(24px, 1.85vw, 32px);
  }
  .editor { min-height: var(--editor-height); }
  .side-panel { gap: clamp(18px, 1.35vw, 24px); }
  .side-card { padding: clamp(20px, 1.5vw, 26px); }
  .dropzone { min-height: clamp(184px, 24vh, 248px); }
  .item-row { min-height: 76px; padding-inline: 20px; }
}

@media (max-width: 820px) {
  .workspace-grid { grid-template-columns: minmax(0, 1fr) 245px; gap: 16px; }
  .composer { padding: 18px; }
}
@media (max-width: 680px) {
  .topbar-inner { min-height: 62px; padding-inline: 16px; }
  .workspace { padding: 26px 14px 36px; }
  .workspace-heading { margin-bottom: 16px; }
  .workspace-grid { grid-template-columns: minmax(0, 1fr); }
  .composer, .side-card { padding: 15px; }
  .side-panel { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 12px; align-items: start; }
  .dropzone { min-height: 145px; }
  .item-row { padding: 8px; gap: 3px; }
  .item-main { gap: 7px; }
  .item-actions { gap: 0; }
  .item-actions .icon-button { width: 34px; height: 36px; }
  .dialog { padding: 20px; }
}
@media (max-width: 355px) {
  .side-panel { grid-template-columns: minmax(0, 1fr); }
  .composer-actions { gap: 6px; }
  .editor-buttons .button { padding-inline: 12px; }
  .gate { padding-inline: 14px; }
}
