/* Personal Digital Atelier • Shared interface */
:root {
  color-scheme: light;
  --canvas: #f5f6f2;
  --surface: #fcfcfa;
  --elevated: #fff;
  --tint: #e8ece8;
  --line: #d7dcda;
  --strong-line: #b9c2bf;
  --ink: #20252a;
  --muted: #59656a;
  --subtle: #65726f;
  --blue: #405e77;
  --accent: #7896b2;
  --cyan: #a9c2c0;
  --button: #26373a;
  --button-ink: #fbfdfb;
  --danger: #a73f39;
  --shadow: 0 18px 55px -33px #24383455;
  --sans: "Inter", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: "IBM Plex Mono", "Cascadia Mono", ui-monospace, monospace;
  --title: clamp(2.12rem, 3.7vw, 4.1rem);
  --subhead: clamp(1.2rem, 1.6vw, 1.55rem);
  --side: clamp(196px, 17vw, 244px);
  --gutter: clamp(24px, 4vw, 72px);
  --immediate: 105ms;
  --fast: 155ms;
  --standard: 240ms;
  --spring: cubic-bezier(.22,.84,.25,1.11);
}
[data-theme="dark"] {
  color-scheme: dark; --canvas: #111518; --surface: #191e22; --elevated: #252b30; --tint: #283034; --line: #343d42; --strong-line: #536066;
  --ink: #e9edeb; --muted: #b6c0c2; --subtle: #9faeae; --blue: #afcede; --accent: #9eb5cb; --cyan: #83a8a6; --button: #dbe7e3; --button-ink: #182120;
  --danger: #ffa197; --shadow: 0 18px 55px -33px #000b;
}
* { box-sizing: border-box; }
html { min-height: 100%; font: 100%/1.55 var(--sans); background: var(--canvas); color: var(--ink); }
body { margin: 0; min-width: 0; background: var(--canvas); color: var(--ink); }
body, input, textarea, select, button { font-family: var(--sans); }
h1,h2,h3,p,figure { margin: 0; }
h1 { font-weight: 560; font-size: var(--title); letter-spacing: -.055em; line-height: 1.18; }
h2 { font-weight: 580; font-size: var(--subhead); letter-spacing: -.035em; line-height: 1.35; }
h3 { font-size: 1.07rem; font-weight: 620; line-height: 1.4; }
small, time, .meta, .muted, .status { color: var(--muted); }
time, code, kbd, pre { font-family: var(--mono); }
small, time, .meta, .status { font-size: .81rem; }
a { color: var(--blue); text-underline-offset: .2em; overflow-wrap: anywhere; }
button, .button { display: inline-flex; align-items: center; justify-content: center; gap: .5em; min-height: 40px; padding: .47em .9em; border: 1px solid var(--strong-line); border-radius: 5px; background: var(--surface); color: var(--ink); font: inherit; font-size: .9rem; font-weight: 530; text-decoration: none; cursor: pointer; transition: transform var(--fast) var(--spring), background-color var(--fast), border-color var(--fast); }
button:active:not(:disabled), .button:active { transform: translateY(1px) scale(.988); }
button:disabled { color: var(--muted); cursor: default; opacity: .65; }
.primary, button.primary { background: var(--button); color: var(--button-ink); border-color: var(--button); }
input, select, textarea, [contenteditable="true"] { max-width: 100%; min-height: 40px; border: 1px solid var(--strong-line); border-radius: 5px; padding: .55em .72em; background: var(--elevated); color: var(--ink); font: inherit; }
input[type="checkbox"], input[type="radio"] { min-height: 0; accent-color: var(--blue); }
input::placeholder, textarea::placeholder { color: var(--subtle); }
textarea { resize: vertical; min-height: 8rem; line-height: 1.75; }
label { display: block; color: var(--muted); font-size: .9rem; }
:where(button,a,input,textarea,select,summary,[tabindex],[contenteditable]):focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
:where(button,a,input,textarea,select)[hidden], [hidden] { display: none !important; }
::selection { background: var(--cyan); color: var(--ink); }
.shell { display: grid; grid-template-columns: var(--side) minmax(0,1fr); min-height: 100vh; min-height: 100svh; }
.sidebar { position: sticky; inset-block-start: 0; max-height: 100vh; max-height: 100dvh; display: flex; flex-direction: column; align-self: start; min-height: 100vh; min-height: 100dvh; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; padding: 24px 14px 16px; border-inline-end: 1px solid var(--line); background: var(--surface); }
.sidebar nav { display: grid; gap: 3px; }
.sidebar :where(button,a) { display: flex; align-items: center; justify-content: flex-start; min-width: 0; width: 100%; min-height: 40px; padding: 9px 12px; border: 0; border-radius: 4px; color: var(--muted); background: transparent; text-decoration: none; text-align: left; overflow-wrap: anywhere; }
.sidebar :where(.active,[aria-current="page"],[aria-selected="true"]) { box-shadow: inset 2px 0 var(--blue); background: var(--tint); color: var(--ink); font-weight: 650; }
.sidebar :where(h2,h3,.brand) { color: var(--ink); margin: 0 8px 16px; }
.sidebar :where(h3,.nav-label) { font-size: .8rem; color: var(--subtle); }
.workspace { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 4; min-height: 62px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px var(--gutter); border-bottom: 1px solid var(--line); background: var(--canvas); }
.topbar > * { min-width: 0; }
#screen { margin-inline: auto; width: 100%; max-width: 1600px; padding: clamp(24px, 4vw, 64px) var(--gutter) 72px; }
#screen > :where(.toolbar,header,section,article,form,.hero,.hub-hero,.rows,.tools,.editor,.grid) + :where(.toolbar,section,article,form,.rows,.tools,.editor,.grid) { margin-top: 24px; }
#screen p { overflow-wrap: anywhere; }
.hub-hero { position: relative; isolation: isolate; overflow: hidden; min-height: clamp(185px,24vw,330px); display: grid; align-content: center; gap: 12px; padding-block: 24px; border-block: 1px solid var(--line); }
.hub-hero :where(h1,h2,p,a,button,small) { position: relative; z-index: 1; }
.hub-hero .atelier-wave { position: absolute; right: -9%; top: 12%; width: 66%; opacity: .85; z-index: -1; }
.hub-hero p { max-width: 49ch; color: var(--muted); }
.toolbar, .actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.toolbar { justify-content: space-between; }
.tools, .grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,205px),1fr)); gap: 12px; }
.tools > :where(button,a,article) { display: flex; align-items: flex-start; justify-content: space-between; flex-direction: column; min-height: 88px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 6px; text-align: left; text-decoration: none; background: var(--surface); color: var(--ink); }
.rows { border-top: 1px solid var(--line); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 14px; width: 100%; min-width: 0; min-height: 54px; padding: 11px 6px; background: transparent; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; text-align: left; overflow-wrap: anywhere; }
.row > * { min-width: 0; }
.empty { padding: 28px 16px; color: var(--muted); text-align: center; background: var(--surface); border: 1px dashed var(--strong-line); }
.editor { display: grid; align-content: start; gap: 16px; padding: clamp(16px,3vw,40px); border: 1px solid var(--line); background: var(--surface); }
.editor :where(input:not([type="checkbox"]):not([type="radio"]),textarea,select,[contenteditable="true"]) { width: 100%; }
.editor textarea, .editor [contenteditable="true"] { min-height: 15rem; }
.editor img, .workspace img { max-width: 100%; height: auto; }
.editor pre { overflow-x: auto; white-space: pre-wrap; }
.status { font-variant-numeric: tabular-nums; }
dialog { max-width: min(670px,calc(100% - 24px)); width: max-content; max-height: 90dvh; overflow: auto; padding: clamp(20px,3vw,36px); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); background: var(--surface); color: var(--ink); }
dialog::backdrop { background: rgb(20 30 31 / 42%); }
dialog form { display: grid; gap: 16px; }
dialog form label > :where(input,textarea,select) { display: block; width: 100%; margin-top: .35em; }
table { border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { border-bottom: 1px solid var(--line); padding: .5em .7em; text-align: start; }
#menu { display: none; }
.login-page { min-height: 100svh; position: relative; }
.login-mast { display: flex; align-items: center; gap: 12px; padding: clamp(20px,3.3vw,48px) clamp(20px,4vw,70px); font-size: .99rem; font-weight: 600; letter-spacing: -.03em; }
.signature { width: 23px; height: 23px; display: inline-block; border: 1.6px solid var(--ink); border-radius: 50% 50% 2px 2px; transform: rotate(18deg); position: relative; }
.signature::before { content: ""; position: absolute; inset: 3px -4px -1px 4px; border: 1.6px solid var(--ink); border-radius: inherit; }
.login-stage { position: relative; isolation: isolate; display: grid; align-content: center; justify-items: center; min-height: calc(100svh - clamp(72px,10vw,122px)); padding: 20px 20px clamp(50px,10vh,120px); overflow: hidden; }
.login-art { position: absolute; z-index: -1; inset: 12% -9% auto; opacity: .85; }
.login-panel { width: min(100%, 415px); padding: clamp(28px,4vw,52px); border: 1px solid var(--line); border-radius: 4px; background: var(--surface); box-shadow: var(--shadow); }
.login-panel h1 { margin-bottom: clamp(26px,3.1vw,44px); font-size: clamp(2rem,3.1vw,3rem); font-weight: 560; }
.login-panel input { width: 100%; margin: 7px 0 18px; min-height: 46px; }
.login-submit { width: 100%; min-height: 46px; justify-content: space-between; padding-inline: 16px; }
.login-error { color: var(--danger); font-size: .88rem; }
.login-error:not(:empty) { margin-bottom: 12px; }
@media (hover:hover) {
  :where(button,.button):hover:not(:disabled) { border-color: var(--muted); }
  .sidebar :where(a,button):hover,.rows > .row:hover { color: var(--ink); background: var(--tint); }
  .tools > :where(a,button):hover { transform: translateY(-2px); box-shadow: var(--shadow); }
}
@media(max-width: 760px) {
  :root { --gutter: clamp(16px,4vw,28px); }
  .shell { display: block; }
  #menu { display: inline-flex; }
  .sidebar { display: none; }
  body.menu-open .sidebar { position: fixed; display: flex; inset: 62px auto 0 0; width: min(85vw,300px); z-index: 8; min-height: 0; max-height: calc(100dvh - 62px); box-shadow: var(--shadow); border-right: 1px solid var(--line); }
  .topbar { gap: 8px; }
  .topbar input { width: 100%; }
  #screen { padding-block: 24px 48px; }
  .hub-hero { min-height: 198px; }
  .hub-hero .atelier-wave { opacity: .33; width: 95%; top: 35%; right: -28%; }
  .row { gap: 8px; }
  button, .button, input, select { min-height: 44px; }
  input[type="checkbox"],input[type="radio"] { min-height: 0; }
  .login-art { inset: 3% -34% auto; }
}
@media(prefers-reduced-motion:reduce), (update:slow) {
  *,*::before,*::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}
[data-motion="off"] *,[data-motion="off"] *::before,[data-motion="off"] *::after { animation: none !important; transition: none !important; }
@media print { .sidebar,.topbar,.toolbar,.actions { display: none !important; } .shell { display:block; } #screen { padding: 0; } }
