:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-soft: #f0f2f5;
  --ink: #212529;
  --muted: #686f78;
  --faint: #9298a1;
  --line: #e1e4e8;
  --line-strong: #c9ced6;
  --accent: #4263eb;
  --accent-dark: #364fc7;
  --accent-soft: #edf2ff;
  --warning: #c2410c;
  --warning-soft: #fff4e6;
  --danger: #d6394c;
  --danger-soft: #fff1f2;
  --shadow: 0 24px 70px rgba(33, 37, 41, .16);
  --on-accent: #ffffff;
  --header-bg: rgba(255,255,255,.96);
  --context-bg: #f1f3f5;
  --hover-bg: #fbfcfe;
  --input-bg: #ffffff;
  --code-bg: #f8f9fa;
  --code-text: #495057;
  --login-bg: #f4f5f7;
  --preview-head-bg: #f8f9fa;
  --accent-wash: #f3f6ff;
  --skill-text: #9c4c0d;
  --skill-soft: #fff4e6;
  --skill-accent: #d9480f;
  --success-line: #bac8ff;
  --success-soft: #edf2ff;
  --danger-line: #ffc9c9;
  --context-hover: rgba(255,255,255,.72);
  --drop-line: #adb5bd;
  --toggle-off: #adb5bd;
  --status-off: #adb5bd;
  --status-on: #4263eb;
  --status-ring: rgba(66,99,235,.14);
  --html-line: #bac8ff;
  --skill-line: #ffd8a8;
  --quiet-mark: #ced4da;
  --window-dot: #ced4da;
  --component-shadow: 0 5px 18px rgba(33,37,41,.07);
  --popover-shadow: 0 15px 40px rgba(33,37,41,.16);
  --window-shadow: 0 30px 80px rgba(33,37,41,.14);
  --share-shadow: 0 24px 70px rgba(33,37,41,.12);
  --active-shadow: 0 1px 2px rgba(33,37,41,.06);
  --backdrop: rgba(17,19,24,.58);
  --preview-shell: #eef0f3;
  --preview-border: #20232a;
  --preview-chrome: #20232a;
  --preview-chrome-muted: #a7adb7;
  --sidebar-shadow: 20px 0 50px rgba(17,19,24,.18);
  --scrim: rgba(17,19,24,.48);
  --primary-icon-filter: brightness(0) invert(1);
  --ease-standard: cubic-bezier(.2,0,0,1);
  --motion-fast: 100ms;
  --motion-base: 160ms;
  --theme-motion-duration: 220ms;
  --theme-motion-ease: cubic-bezier(.22, 1, .36, 1);
  --font: "Avenir Next", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: "SFMono-Regular", "Roboto Mono", "Liberation Mono", monospace;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111318;
  --surface: #181b21;
  --surface-soft: #20242c;
  --ink: #eceef2;
  --muted: #a8afba;
  --faint: #777f8b;
  --line: #232831;
  --line-strong: #2b3039;
  --accent: #8b94c7;
  --accent-dark: #9da6d8;
  --accent-soft: #24283a;
  --warning: #b19a6c;
  --warning-soft: #2b271f;
  --danger: #c1848c;
  --danger-soft: #302329;
  --shadow: 0 28px 80px rgba(0, 0, 0, .3);
  --on-accent: #111318;
  --header-bg: rgba(24,27,33,.96);
  --context-bg: #16191f;
  --hover-bg: #20242c;
  --input-bg: #16191f;
  --code-bg: #16191f;
  --code-text: #a8afba;
  --login-bg: #111318;
  --preview-head-bg: #181b21;
  --accent-wash: #202434;
  --skill-text: #c7a99d;
  --skill-soft: #2b2422;
  --skill-accent: #b08f81;
  --success-line: #41554f;
  --success-soft: #1d2926;
  --danger-line: #604149;
  --context-hover: #20242c;
  --drop-line: #454b55;
  --toggle-off: #555d68;
  --status-off: #626a75;
  --status-on: #8b94c7;
  --status-ring: rgba(139,148,199,.18);
  --html-line: #465968;
  --skill-line: #59483f;
  --quiet-mark: #3d434c;
  --window-dot: #454b55;
  --component-shadow: 0 8px 24px rgba(0,0,0,.16);
  --popover-shadow: 0 18px 48px rgba(0,0,0,.28);
  --window-shadow: 0 30px 90px rgba(0,0,0,.34);
  --share-shadow: 0 26px 80px rgba(0,0,0,.26);
  --active-shadow: 0 1px 2px rgba(0,0,0,.18);
  --backdrop: rgba(5,7,10,.66);
  --preview-shell: #111318;
  --preview-border: #2b3039;
  --preview-chrome: #181b21;
  --preview-chrome-muted: #a8afba;
  --sidebar-shadow: 20px 0 50px rgba(0,0,0,.28);
  --scrim: rgba(5,7,10,.58);
  --primary-icon-filter: brightness(0);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-height: 100%; }
body { margin: 0; color: var(--ink); background: var(--bg); font-family: var(--font); font-size: 14px; letter-spacing: 0; -webkit-font-smoothing: antialiased; }
html.theme-transition *, html.theme-transition *::before, html.theme-transition *::after { transition: background-color var(--theme-motion-duration) var(--theme-motion-ease), color var(--theme-motion-duration) var(--theme-motion-ease), border-color var(--theme-motion-duration) var(--theme-motion-ease), box-shadow var(--theme-motion-duration) var(--theme-motion-ease), fill var(--theme-motion-duration) var(--theme-motion-ease), stroke var(--theme-motion-duration) var(--theme-motion-ease), filter var(--theme-motion-duration) var(--theme-motion-ease), opacity var(--theme-motion-duration) var(--theme-motion-ease) !important; }
html.theme-transition .theme-button img { animation: theme-icon-settle var(--theme-motion-duration) var(--theme-motion-ease) both; }
html[data-theme="dark"] img[src^="/icons/"] { filter: invert(.9); }
button, input, select { font: inherit; color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
img { display: block; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.brand-link { min-width: 0; display: inline-flex; align-items: center; gap: 11px; }
.brand-symbol {
  display: inline-flex;
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 6px;
  color: var(--on-accent);
  background: var(--accent);
  font-size: 0;
  line-height: 0;
}
.brand-symbol::before { content: "MG"; display: block; font-size: 11px; font-weight: 800; line-height: 1; }
.brand-link > span:last-child { min-width: 0; display: grid; gap: 2px; }
.brand-link strong { font-size: 14px; line-height: 1.1; }
.brand-link small { color: var(--muted); font-size: 10px; }

.button { position: relative; height: 40px; padding: 0 15px; border: 1px solid transparent; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: transparent; cursor: pointer; font-weight: 650; white-space: nowrap; transition: background-color var(--motion-fast) ease, border-color var(--motion-fast) ease, color var(--motion-fast) ease; }
.button img { width: 17px; height: 17px; }
.button.primary { color: var(--on-accent); background: var(--accent); border-color: var(--accent); }
.button.primary img { filter: var(--primary-icon-filter); }
.button.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.button.secondary { background: var(--surface); border-color: var(--line-strong); }
.button.secondary:hover { border-color: var(--muted); }
.button:disabled, .icon-button:disabled, .batch-action:disabled { opacity: .62; cursor: wait; transform: none; }
.button.is-submitting::after, .icon-button.is-submitting::after { content: ""; width: 14px; height: 14px; flex: 0 0 auto; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.icon-button.is-submitting img { display: none; }

.icon-button { width: 36px; height: 36px; padding: 0; border: 1px solid transparent; border-radius: 6px; display: inline-grid; place-items: center; background: transparent; cursor: pointer; flex: 0 0 auto; transition: background-color var(--motion-fast) ease, border-color var(--motion-fast) ease; }
.icon-button:hover { background: var(--surface-soft); border-color: var(--line); }
.icon-button img { width: 18px; height: 18px; }
.icon-button.compact { width: 30px; height: 30px; }
.icon-button.compact img { width: 16px; height: 16px; }
.theme-button { width: 36px; height: 36px; border-color: var(--line); background: var(--surface); }
.theme-button:hover { border-color: var(--line-strong); background: var(--surface-soft); }

@keyframes theme-icon-settle {
  0% { opacity: .45; transform: rotate(-18deg) scale(.82); }
  100% { opacity: 1; transform: rotate(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  html.theme-transition *, html.theme-transition *::before, html.theme-transition *::after { transition-duration: 0ms !important; }
  html.theme-transition .theme-button img { animation: none; }
}

/* Global application structure */
.app-header { position: sticky; z-index: 40; top: 0; height: 68px; padding: 0 22px; display: grid; grid-template-columns: 225px auto minmax(220px, 460px) auto; align-items: center; gap: 18px; background: var(--header-bg); border-bottom: 1px solid var(--line); backdrop-filter: blur(14px); }
.workspace-tabs { height: 100%; display: flex; align-items: stretch; gap: 4px; }
.workspace-tabs a { position: relative; min-width: 116px; padding: 0 13px; display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--muted); font-weight: 600; transition: color var(--motion-fast) ease; }
.workspace-tabs a::after { content: ""; position: absolute; left: 14px; right: 14px; bottom: -1px; height: 2px; background: var(--accent); transform: scaleX(0); transform-origin: center; transition: transform var(--motion-base) var(--ease-standard); }
.workspace-tabs a:hover { color: var(--ink); }
.workspace-tabs a.active { color: var(--ink); }
.workspace-tabs a.active::after { transform: scaleX(1); }
.workspace-tabs img { width: 17px; height: 17px; }
.workspace-tabs small { min-width: 20px; height: 18px; padding: 0 5px; display: inline-grid; place-items: center; border-radius: 9px; background: var(--surface-soft); color: var(--muted); font-size: 10px; }
.header-search { position: relative; height: 38px; }
.header-search > img { position: absolute; left: 12px; top: 10px; width: 17px; opacity: .55; }
.header-search input { width: 100%; height: 100%; padding: 0 14px 0 38px; border: 1px solid var(--line); border-radius: 7px; background: var(--bg); transition: background-color var(--motion-fast) ease, border-color var(--motion-fast) ease, box-shadow var(--motion-base) ease; }
.header-search input:focus { background: var(--surface); border-color: var(--accent); outline: 1px solid var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.search-clear { position: absolute; right: 6px; top: 5px; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 5px; }
.search-clear:hover { background: var(--surface-soft); }
.search-clear img { width: 14px; }
.header-search:has(.search-clear) input { padding-right: 38px; }
.header-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.header-actions form { display: flex; }
.ai-button { max-width: 190px; height: 36px; padding: 0 11px; border: 1px solid var(--line); border-radius: 6px; display: flex; align-items: center; gap: 7px; background: var(--surface); cursor: pointer; transition: border-color var(--motion-fast) ease, background-color var(--motion-fast) ease; }
.ai-button:hover { border-color: var(--line-strong); background: var(--surface-soft); }
.ai-button > img { width: 15px; }
.ai-button > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.status-dot { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: var(--status-off); }
.status-dot.online { background: var(--status-on); box-shadow: 0 0 0 3px var(--status-ring); }
.context-toggle { display: none; }

.workspace-shell { min-height: calc(100vh - 68px); display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.context-sidebar { position: sticky; top: 68px; height: calc(100vh - 68px); padding: 20px 14px 14px; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; background: var(--context-bg); border-right: 1px solid var(--line); }
.context-head { min-height: 48px; padding: 0 8px 12px; display: flex; align-items: center; gap: 6px; }
.context-head > div { min-width: 0; flex: 1; display: grid; gap: 2px; }
.context-head small { color: var(--muted); font-size: 10px; }
.context-head strong { font-size: 15px; }
.context-close { display: none; }
.context-nav { min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; scrollbar-width: thin; }
.context-item { min-height: 38px; padding: 0 9px; border-radius: 6px; display: grid; grid-template-columns: 17px minmax(0, 1fr) auto; align-items: center; gap: 9px; color: var(--muted); transition: color var(--motion-fast) ease, background-color var(--motion-fast) ease; }
.context-item:hover { color: var(--ink); background: var(--context-hover); }
.context-item.active { color: var(--accent-dark); background: var(--surface); box-shadow: var(--active-shadow); font-weight: 650; }
.context-item img { width: 16px; height: 16px; }
.context-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.context-item small { color: var(--faint); font-size: 10px; }
.context-item.depth-1 { padding-left: 24px; }
.context-item.depth-2 { padding-left: 39px; }
.context-item.depth-3, .context-item.depth-4 { padding-left: 54px; }
.context-foot { padding: 14px 8px 2px; display: flex; justify-content: space-between; color: var(--faint); font-size: 10px; border-top: 1px solid var(--line); }
.context-scrim { display: none; }

.main-workspace { min-width: 0; padding: 30px clamp(26px, 4vw, 58px) 70px; }
.notice { min-height: 42px; margin-bottom: 18px; padding: 8px 9px 8px 12px; display: flex; align-items: center; gap: 9px; border: 1px solid; border-radius: 6px; background: var(--surface); }
.notice.is-leaving { animation: notice-out .12s ease both; pointer-events: none; }
.notice > img { width: 17px; }
.notice > span { flex: 1; }
.notice.success { color: var(--accent-dark); border-color: var(--success-line); background: var(--success-soft); }
.notice.error { color: var(--danger); border-color: var(--danger-line); background: var(--danger-soft); }
.page-head { min-height: 105px; display: flex; align-items: flex-start; justify-content: space-between; gap: 28px; }
.breadcrumbs { min-height: 18px; display: flex; flex-wrap: wrap; align-items: center; gap: 5px; color: var(--muted); font-size: 11px; }
.breadcrumbs img { width: 13px; opacity: .45; }
.breadcrumbs a:hover { color: var(--accent); }
.page-title-row { margin-top: 9px; display: flex; align-items: center; gap: 7px; }
.page-title-row h1 { margin: 0; max-width: min(760px, 65vw); overflow-wrap: anywhere; font-size: 29px; line-height: 1.18; letter-spacing: 0; }
.page-head p { margin: 7px 0 0; color: var(--muted); font-size: 12px; }
.page-actions { padding-top: 20px; display: flex; gap: 8px; flex: 0 0 auto; }

.collections-section { margin-top: 10px; padding-bottom: 30px; }
.section-head { display: flex; align-items: center; gap: 8px; }
.section-head h2 { margin: 0; font-size: 13px; }
.section-head > span { min-width: 20px; height: 18px; padding: 0 5px; display: inline-grid; place-items: center; border-radius: 9px; color: var(--muted); background: var(--surface-soft); font-size: 10px; }
.collection-grid { margin-top: 11px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.collection-item { position: relative; min-width: 0; height: 70px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); transition: border-color var(--motion-fast) ease, background-color var(--motion-fast) ease; }
.collection-item:hover { border-color: var(--line-strong); background: var(--hover-bg); }
.collection-item > a { height: 100%; padding: 10px 42px 10px 11px; display: flex; align-items: center; gap: 11px; }
.collection-icon { width: 40px; height: 40px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 6px; color: var(--accent-dark); background: var(--accent-soft); }
.collection-icon.skill { color: var(--skill-accent); background: var(--warning-soft); }
.collection-icon img { width: 20px; }
.collection-item > a > span:last-child { min-width: 0; display: grid; gap: 4px; }
.collection-item strong, .collection-item small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.collection-item small { color: var(--muted); font-size: 10px; }
.collection-item > .icon-button { position: absolute; top: 9px; right: 6px; opacity: 0; transition: opacity var(--motion-fast) ease; }
.collection-item:hover > .icon-button, .collection-item:focus-within > .icon-button { opacity: 1; }

.resource-section { margin-top: 10px; }
.resource-toolbar { min-height: 44px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line-strong); }
.sort-control { position: relative; display: flex; align-items: center; }
.sort-control img { position: absolute; left: 7px; width: 14px; opacity: .55; pointer-events: none; }
.sort-control select { height: 34px; padding: 0 7px 0 27px; border: 0; border-radius: 5px; background: transparent; color: var(--muted); cursor: pointer; font-size: 11px; transition: color var(--motion-fast) ease, background-color var(--motion-fast) ease; }
.sort-control select:hover { color: var(--ink); background: var(--surface-soft); }
.resource-list { background: var(--surface); border-bottom: 1px solid var(--line); }
.resource-row { position: relative; min-height: 88px; padding: 12px 10px; display: grid; grid-template-columns: minmax(250px, 1.05fr) minmax(280px, 1.3fr) 134px 70px 34px; gap: 18px; align-items: center; border-top: 1px solid var(--line); transition: background-color var(--motion-fast) ease; }
.resource-row:hover { background: var(--hover-bg); }
.resource-row.pending::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 2px; border-radius: 1px; background: var(--warning); }
.resource-main { min-width: 0; padding: 0; border: 0; display: flex; align-items: center; gap: 11px; background: transparent; text-align: left; cursor: pointer; }
.resource-main:hover strong { color: var(--accent); }
.resource-main > span:last-child { min-width: 0; display: grid; gap: 4px; }
.resource-main strong, .resource-main small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.resource-main strong { font-size: 13px; transition: color var(--motion-fast) ease; }
.resource-main small { color: var(--muted); font: 10px/1.2 var(--mono); }
.resource-icon { width: 40px; height: 44px; display: grid; place-items: center; flex: 0 0 auto; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-soft); }
.resource-icon.html { color: var(--accent-dark); background: var(--accent-soft); border-color: var(--html-line); }
.resource-icon.skill { color: var(--skill-accent); background: var(--warning-soft); border-color: var(--skill-line); }
.resource-icon img { width: 19px; }
.resource-description { min-width: 0; }
.resource-description p { margin: 5px 0 0; overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.resource-location { display: flex; align-items: center; gap: 5px; overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; font-size: 10px; }
.resource-location img { width: 13px; }
.resource-row time, .resource-size { color: var(--muted); font: 9px/1.45 var(--mono); }
.analysis-state { display: inline-flex; align-items: center; gap: 7px; margin-top: 6px; color: var(--warning); font-size: 11px; }
.analysis-state i { width: 7px; height: 7px; border-radius: 50%; background: var(--warning); animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; transform: scale(.75); } }
.tag-list { margin-top: 6px; display: flex; gap: 5px; overflow: hidden; }
.tag-list span { height: 18px; padding: 0 6px; display: inline-flex; align-items: center; flex: 0 0 auto; border-radius: 4px; color: var(--muted); background: var(--surface-soft); font-size: 9px; }
.skill-metrics { margin-top: 6px; display: flex; gap: 5px; }
.skill-metrics span { padding: 2px 6px; border-radius: 4px; color: var(--skill-text); background: var(--skill-soft); font-size: 9px; }

.action-menu { position: relative; }
.action-menu summary { list-style: none; }
.action-menu summary::-webkit-details-marker { display: none; }
.action-menu[open] summary { background: var(--surface-soft); border-color: var(--line); }
.action-popover { position: absolute; z-index: 30; top: 35px; right: 0; width: 190px; padding: 5px; display: grid; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--surface); box-shadow: var(--popover-shadow); }
.action-menu[open] .action-popover { animation: popover-in .1s ease-out both; transform-origin: top right; }
.action-popover button, .action-popover a { width: 100%; min-height: 34px; padding: 0 9px; border: 0; border-radius: 5px; display: flex; align-items: center; gap: 8px; background: transparent; text-align: left; cursor: pointer; font-size: 11px; transition: background-color var(--motion-fast) ease; }
.action-popover button:hover, .action-popover a:hover { background: var(--surface-soft); }
.action-popover img { width: 15px; }
.action-popover .danger { color: var(--danger); }
.empty-state { min-height: 330px; display: grid; place-items: center; align-content: center; text-align: center; background: var(--surface); border-bottom: 1px solid var(--line); }
.empty-icon { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 8px; color: var(--accent-dark); background: var(--accent-soft); }
.empty-icon.skill { color: var(--skill-accent); background: var(--warning-soft); }
.empty-icon img { width: 24px; }
.empty-state h2 { margin: 17px 0 0; font-size: 18px; }
.empty-state p { margin: 6px 0 20px; color: var(--muted); font-size: 12px; }

/* Forms and dialogs */
dialog { color: var(--ink); }
.modal { width: min(560px, calc(100vw - 28px)); max-height: calc(100vh - 28px); padding: 0; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.modal[open], .preview-modal[open] { animation: modal-in .12s ease-out both; }
.modal.is-closing, .preview-modal.is-closing { animation: modal-out .1s ease-in both; pointer-events: none; }
.modal::backdrop, .preview-modal::backdrop { background: var(--backdrop); }
dialog[open]::backdrop { animation: backdrop-in .12s ease both; }
.modal.is-closing::backdrop, .preview-modal.is-closing::backdrop { animation: backdrop-out .1s ease both; }
.modal-shell { padding: 23px; }
.modal-head { margin-bottom: 22px; display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.modal-head > div { min-width: 0; }
.modal-head small { color: var(--accent); font-size: 10px; font-weight: 700; }
.modal-head h2 { margin: 4px 0 0; overflow-wrap: anywhere; font-size: 22px; }
.field { margin-bottom: 16px; display: grid; gap: 7px; }
.field > span { display: flex; justify-content: space-between; font-size: 12px; font-weight: 650; }
.field > span small { color: var(--faint); font-weight: 400; }
.field input, .field select { width: 100%; height: 44px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--input-bg); transition: border-color var(--motion-fast) ease, box-shadow var(--motion-base) ease; }
.field input:focus, .field select:focus { border-color: var(--accent); outline: 1px solid var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.form-stack { display: grid; }
.form-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-actions { margin-top: 20px; padding-top: 16px; display: flex; align-items: center; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--line); }
.form-actions.split { justify-content: space-between; }
.form-actions > div { display: flex; gap: 8px; }
.text-button { min-height: 34px; padding: 0; border: 0; display: inline-flex; align-items: center; gap: 7px; background: transparent; cursor: pointer; font-size: 11px; }
.text-button img { width: 15px; }
.text-button.danger { color: var(--danger); }
#delete-folder-form, #delete-group-form { display: none; }
.drop-zone { min-height: 174px; margin-bottom: 17px; display: flex; flex-direction: column; align-items: center; justify-content: center; border: 1px dashed var(--drop-line); border-radius: 7px; background: var(--bg); cursor: pointer; transition: border-color var(--motion-fast) ease, background-color var(--motion-fast) ease; }
.drop-zone:hover, .drop-zone.dragging { border-color: var(--accent); background: var(--accent-wash); }
.drop-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop-zone > span { width: 44px; height: 44px; margin-bottom: 11px; display: grid; place-items: center; border-radius: 8px; color: var(--accent-dark); background: var(--accent-soft); }
.drop-zone > span.skill { color: var(--skill-accent); background: var(--warning-soft); }
.drop-zone img { width: 21px; }
.drop-zone strong { max-width: 85%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drop-zone small { margin-top: 5px; color: var(--muted); font-size: 10px; }
.switch-row { min-height: 58px; padding: 10px 0; display: flex; align-items: center; justify-content: space-between; gap: 18px; border-top: 1px solid var(--line); cursor: pointer; }
.switch-row > span { display: grid; gap: 3px; }
.switch-row small { color: var(--muted); font-size: 10px; }
.switch-row input { position: absolute; opacity: 0; }
.switch-row i { position: relative; width: 40px; height: 22px; flex: 0 0 auto; border-radius: 11px; background: var(--toggle-off); transition: background-color var(--motion-base) ease, box-shadow var(--motion-base) ease; }
.switch-row i::after { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; border-radius: 50%; background: var(--on-accent); box-shadow: 0 1px 3px rgba(0,0,0,.22); transition: transform var(--motion-base) var(--ease-standard); }
.switch-row input:checked + i { background: var(--accent); }
.switch-row input:checked + i::after { transform: translateX(18px); }
.switch-row input:focus-visible + i { box-shadow: 0 0 0 4px var(--accent-soft); }
.switch-row.disabled { opacity: .48; cursor: not-allowed; }

.settings-modal { width: min(650px, calc(100vw - 28px)); }
.settings-tabs { height: 42px; margin-bottom: 18px; display: flex; border-bottom: 1px solid var(--line); }
.settings-tabs button { height: 42px; padding: 0 14px; border: 0; border-bottom: 2px solid transparent; display: inline-flex; align-items: center; gap: 7px; background: transparent; color: var(--muted); cursor: pointer; font-weight: 600; transition: color var(--motion-fast) ease, border-color var(--motion-fast) ease; }
.settings-tabs button img { width: 16px; }
.settings-tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.settings-panel.active { animation: panel-in .15s ease both; }
@keyframes panel-in { from { opacity: 0; transform: translateY(4px); } }
.connection-status { min-height: 38px; margin-bottom: 17px; padding: 9px 10px; display: flex; align-items: center; gap: 8px; border-radius: 6px; background: var(--surface-soft); }
.connection-status > img { width: 17px; }
.connection-status small { margin-left: auto; color: var(--muted); font-size: 9px; }
.batch-action { width: 100%; min-height: 48px; margin-top: 11px; padding: 0 12px; border: 1px solid var(--line); border-radius: 6px; display: flex; align-items: center; justify-content: space-between; background: var(--surface); cursor: pointer; transition: border-color var(--motion-fast) ease, background-color var(--motion-fast) ease; }
.batch-action:hover { border-color: var(--accent); background: var(--accent-wash); }
.batch-action > span { display: flex; align-items: center; gap: 8px; }
.batch-action img { width: 16px; }

.loading-state, .skill-detail-loading { min-height: 150px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: var(--muted); }
.loading-state i, .skill-detail-loading i { width: 26px; height: 26px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.share-result { display: grid; gap: 15px; }
.copy-field { display: grid; gap: 6px; }
.copy-field > span:first-child { font-size: 11px; font-weight: 650; }
.copy-field > span:last-child { height: 44px; display: grid; grid-template-columns: minmax(0,1fr) 43px; border: 1px solid var(--line-strong); border-radius: 6px; overflow: hidden; }
.copy-field input { min-width: 0; padding: 0 11px; border: 0; background: var(--input-bg); font: 10px/1 var(--mono); }
.copy-field .icon-button { width: 42px; height: 42px; border-left: 1px solid var(--line); border-radius: 0; }
.copy-field.code input { color: var(--accent-dark); font-size: 17px; font-weight: 800; }
.share-note { min-height: 36px; margin: 0; padding: 8px 10px; display: flex; align-items: center; gap: 7px; border-radius: 5px; color: var(--muted); background: var(--surface-soft); font-size: 10px; }
.share-note img { width: 15px; }
.copied { color: var(--accent) !important; border-color: var(--accent) !important; }
.preview-modal { width: min(1480px, calc(100vw - 26px)); height: min(900px, calc(100vh - 26px)); padding: 0; border: 1px solid var(--preview-border); border-radius: 8px; background: var(--preview-shell); box-shadow: var(--shadow); }
.preview-head { height: 52px; padding: 0 9px 0 15px; display: flex; align-items: center; justify-content: space-between; color: #fff; background: var(--preview-chrome); }
.preview-head > div { min-width: 0; display: flex; align-items: center; gap: 8px; }
.preview-head > div:first-child { display: grid; gap: 2px; }
.preview-head small { color: var(--preview-chrome-muted); font-size: 9px; }
.preview-head strong { max-width: min(760px, 60vw); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-head .icon-button img { filter: brightness(0) invert(1); }
.preview-modal iframe { width: 100%; height: calc(100% - 52px); border: 0; background: #fff; }

/* Skill detail */
.skill-detail-modal { width: min(700px, calc(100vw - 28px)); }
.skill-detail-meta { display: flex; align-items: center; gap: 8px; }
.skill-detail-meta code { padding: 5px 8px; border-radius: 5px; color: var(--accent-dark); background: var(--accent-soft); font: 11px/1 var(--mono); }
.skill-detail-meta span { color: var(--muted); font-size: 11px; }
.skill-detail-description { margin: 15px 0; color: var(--muted); line-height: 1.65; }
.skill-detail-stats { display: flex; flex-wrap: wrap; gap: 6px; }
.skill-detail-stats span { padding: 5px 8px; border-radius: 5px; background: var(--surface-soft); color: var(--muted); font-size: 10px; }
.skill-warning-list { margin-top: 12px; display: grid; gap: 5px; }
.skill-warning-list span { padding: 7px 9px; border-radius: 5px; color: var(--warning); background: var(--warning-soft); font-size: 10px; }
.instruction-preview { margin-top: 17px; }
.instruction-preview > strong { font-size: 11px; }
.instruction-preview pre { max-height: 260px; margin: 8px 0 0; padding: 13px; overflow: auto; border: 1px solid var(--line); border-radius: 6px; background: var(--code-bg); color: var(--code-text); white-space: pre-wrap; font: 10px/1.55 var(--mono); }

/* Login */
.login-page { min-height: 100vh; overflow-x: hidden; background: var(--login-bg); }
.login-header { width: min(100%, 1280px); height: 76px; margin: 0 auto; padding: 0 clamp(22px, 4vw, 58px); display: flex; align-items: center; justify-content: space-between; }
.login-header-actions { display: flex; align-items: center; gap: 12px; }
.login-private-state { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 10px; font-weight: 650; letter-spacing: 0; }
.login-private-state i { width: 6px; height: 6px; border-radius: 50%; background: var(--status-on); box-shadow: 0 0 0 4px var(--status-ring); }
.login-layout { width: min(100%, 1180px); min-height: calc(100vh - 76px); margin: 0 auto; padding: 48px 32px 72px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(380px, 420px); align-items: center; gap: clamp(60px, 8vw, 112px); }
.login-identity { min-width: 0; max-width: 580px; animation: login-enter 380ms cubic-bezier(.2,.8,.2,1) both; }
.login-archive-motif { position: relative; width: 74px; height: 52px; margin-bottom: 28px; }
.login-archive-motif i { position: absolute; left: 0; width: 58px; height: 34px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: 0 8px 20px rgba(31,43,84,.045); }
.login-archive-motif i:nth-child(1) { top: 0; left: 16px; border-top-color: #c9a08f; }
.login-archive-motif i:nth-child(2) { top: 8px; left: 8px; border-top-color: #8ea2b8; }
.login-archive-motif i:nth-child(3) { top: 16px; border-top-color: #6974b8; }
.login-kicker, .login-access-kicker { display: inline-block; color: var(--accent); font-size: 11px; font-weight: 700; letter-spacing: 0; }
.login-identity h1 { margin: 11px 0 0; font-size: 36px; font-weight: 700; line-height: 1.2; letter-spacing: 0; }
.login-identity > p { margin: 11px 0 0; color: var(--muted); font-size: 15px; line-height: 1.6; }
.login-index { margin-top: 42px; border-top: 1px solid var(--line); }
.login-index article { min-height: 72px; padding: 13px 4px; display: grid; grid-template-columns: 40px minmax(0, 1fr); align-items: center; gap: 14px; border-bottom: 1px solid var(--line); transition: background-color var(--motion-base) ease, padding-inline var(--motion-base) ease; }
.login-index article:hover { padding-inline: 10px; background: var(--surface); }
.login-index-icon { display: grid; width: 38px; height: 38px; place-items: center; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.login-index-icon img { width: 17px; height: 17px; }
.login-index-icon.html { color: #6974b8; background: color-mix(in srgb, var(--surface) 88%, #6974b8 12%); }
.login-index-icon.skill { color: #8b7ea4; background: color-mix(in srgb, var(--surface) 88%, #8b7ea4 12%); }
.login-index-icon.share { color: #6f8fa6; background: color-mix(in srgb, var(--surface) 88%, #6f8fa6 12%); }
.login-index article > span:last-child { display: grid; gap: 4px; }
.login-index strong { font-size: 14px; font-weight: 650; }
.login-index small { color: var(--muted); font-size: 12px; line-height: 1.45; }
.login-access-panel { width: 100%; padding: 31px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); box-shadow: 0 24px 64px rgba(31,43,84,.09); animation: login-enter 380ms 80ms cubic-bezier(.2,.8,.2,1) both; }
.login-copy { margin-bottom: 25px; }
.login-copy h2 { margin: 9px 0 0; font-size: 26px; font-weight: 700; line-height: 1.3; letter-spacing: 0; }
.login-copy p { margin: 8px 0 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.login-message { min-height: 42px; margin-bottom: 15px; padding: 10px 11px; display: flex; align-items: center; gap: 9px; border: 1px solid; border-radius: 10px; font-size: 12px; line-height: 1.45; }
.login-message img { width: 16px; }
.login-message.success { color: var(--accent-dark); border-color: var(--success-line); background: var(--success-soft); }
.login-message.error { color: var(--danger); border-color: var(--danger-line); background: var(--danger-soft); }
.login-form { display: grid; }
.password-input > span:last-child { position: relative; display: block; }
.password-input input { padding-right: 48px; }
.password-input .icon-button { position: absolute; right: 4px; bottom: 4px; }
.login-page .field > span:first-child { font-size: 12px; font-weight: 650; }
.login-page .field input { height: 50px; border-radius: 10px; }
.login-page .password-input .icon-button { right: 5px; bottom: 5px; width: 40px; height: 40px; border-radius: 8px; }
.login-submit { width: 100%; height: 50px; margin-top: 2px; padding-inline: 17px; justify-content: space-between; border-radius: 10px; }
.login-security { margin-top: 19px; padding-top: 17px; display: grid; gap: 7px; border-top: 1px solid var(--line); color: var(--faint); }
.login-security span { display: flex; align-items: center; gap: 7px; font-size: 11px; }
.login-security small { padding-left: 22px; font-size: 10px; }
.login-security img { width: 15px; }
@keyframes login-enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* Public one-time share */
.share-page { min-height: 100vh; background: var(--context-bg); }
.share-access-shell { width: min(100%, 720px); min-height: 100vh; margin: 0 auto; padding: 38px 24px 28px; display: grid; grid-template-rows: auto 1fr auto; }
.share-brand { display: flex; align-items: center; gap: 10px; }
.share-brand .theme-button { margin-left: auto; }
.share-brand > span:last-child { display: grid; gap: 2px; }
.share-brand small { color: var(--muted); font-size: 9px; }
.share-access-panel { width: min(100%, 500px); margin: auto; padding: 34px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: var(--share-shadow); }
.eyebrow { margin: 0 0 11px; color: var(--accent); font-size: 10px; font-weight: 700; }
.share-access-panel h1 { margin: 0; overflow-wrap: anywhere; font-size: 27px; line-height: 1.25; }
.share-access-meta { margin: 9px 0 26px; color: var(--muted); font-size: 11px; }
.share-access-form { display: grid; gap: 9px; }
.share-access-form label { font-size: 11px; font-weight: 650; }
.share-access-form input { height: 48px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--input-bg); text-transform: uppercase; font: 750 16px/1 var(--mono); }
.share-access-form input:focus { border-color: var(--accent); outline: 1px solid var(--accent); }
.share-access-form .button { height: 44px; margin-top: 3px; justify-content: space-between; }
.share-unavailable { min-height: 140px; margin-top: 24px; display: grid; place-items: center; align-content: center; gap: 10px; border-radius: 6px; color: var(--danger); background: var(--danger-soft); }
.share-unavailable img { width: 28px; }
.share-access-shell footer { color: var(--faint); font-size: 9px; }
.shared-view-page { height: 100vh; overflow: hidden; background: var(--bg); }
.shared-view-head { height: 60px; padding: 0 18px; display: flex; align-items: center; justify-content: space-between; background: var(--surface); border-bottom: 1px solid var(--line); }
.shared-view-actions { display: flex; align-items: center; gap: 8px; }
.shared-view-head .brand-link strong { max-width: 60vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share-security { display: flex; align-items: center; gap: 6px; color: var(--accent-dark); font-size: 10px; }
.share-security img { width: 15px; }
.shared-view-page iframe { width: 100%; height: calc(100vh - 60px); border: 0; background: #fff; }

@media (max-width: 1180px) {
  .app-header { grid-template-columns: 190px auto minmax(180px, 1fr) auto; gap: 10px; }
  .workspace-tabs a { min-width: 100px; padding: 0 9px; }
  .resource-row { grid-template-columns: minmax(220px, 1fr) minmax(230px, 1.1fr) 120px 34px; }
  .resource-size { display: none; }
  .collection-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 920px) {
  .app-header { grid-template-columns: auto 1fr auto; padding: 0 16px; }
  .header-brand { display: none; }
  .workspace-tabs { order: 1; }
  .header-search { order: 2; }
  .header-actions { order: 3; }
  .ai-button > span:last-child { display: none; }
  .ai-button { width: 38px; padding: 0; justify-content: center; }
  .ai-button .status-dot { position: absolute; margin: -24px 0 0 25px; }
  .context-toggle { display: inline-grid; }
  .workspace-shell { display: block; }
  .context-sidebar { position: fixed; z-index: 50; top: 0; left: 0; width: 280px; height: 100vh; transform: translateX(-102%); transition: transform .18s var(--ease-standard); box-shadow: var(--sidebar-shadow); }
  .context-open .context-sidebar { transform: translateX(0); }
  .context-open { overflow: hidden; }
  .context-scrim { position: fixed; z-index: 49; inset: 0; display: block; background: var(--scrim); opacity: 0; visibility: hidden; pointer-events: none; transition: opacity var(--motion-base) ease, visibility var(--motion-base) ease; }
  .context-open .context-scrim { opacity: 1; visibility: visible; pointer-events: auto; }
  .context-close { display: inline-grid; }
  .resource-row { grid-template-columns: minmax(220px,1fr) minmax(230px,1fr) 34px; }
  .resource-row time, .resource-size { display: none; }
  .login-layout { grid-template-columns: minmax(0, 1fr) minmax(360px, 410px); gap: 48px; }
}

@media (max-width: 700px) {
  .app-header { height: 62px; padding: 0 11px; grid-template-columns: auto minmax(0,1fr) auto; }
  .workspace-tabs a { min-width: 45px; padding: 0 8px; }
  .workspace-tabs a span, .workspace-tabs a small { display: none; }
  .workspace-tabs a::after { left: 7px; right: 7px; }
  .header-search { height: 36px; }
  .header-actions { gap: 2px; }
  .main-workspace { padding: 23px 15px 50px; }
  .page-head { min-height: 0; display: block; }
  .page-title-row h1 { max-width: calc(100vw - 72px); font-size: 25px; }
  .page-actions { padding: 17px 0 25px; display: grid; grid-template-columns: 1fr 1fr; }
  .page-actions .button { padding: 0 10px; }
  .collections-section { padding-bottom: 22px; }
  .collection-grid { grid-template-columns: 1fr; }
  .collection-item > .icon-button { opacity: 1; }
  .resource-row { min-height: 0; padding: 14px 5px; grid-template-columns: minmax(0,1fr) 32px; gap: 10px; }
  .resource-main { grid-column: 1; }
  .resource-description { grid-column: 1; padding-left: 51px; margin-top: -3px; }
  .resource-description p { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .action-menu { grid-column: 2; grid-row: 1; }
  .action-popover { position: fixed; top: auto; left: 10px; right: 10px; bottom: 10px; width: auto; padding: 7px; }
  .action-menu[open] .action-popover { animation-name: sheet-in; transform-origin: bottom center; }
  .form-columns { grid-template-columns: 1fr; gap: 0; }
  .form-actions.split { align-items: stretch; flex-direction: column-reverse; }
  .form-actions.split > div { display: grid; grid-template-columns: 1fr 1fr; }
  .modal-shell { padding: 19px; }
  .preview-modal { width: 100vw; height: 100vh; max-width: none; max-height: none; border: 0; border-radius: 0; }
  .preview-head strong { max-width: 55vw; }
  .login-header { height: 64px; padding: 0 18px; }
  .login-private-state { display: none; }
  .login-layout { min-height: calc(100vh - 64px); padding: 26px 20px 42px; display: block; }
  .login-identity { max-width: 430px; margin: 0 auto; }
  .login-archive-motif { width: 58px; height: 38px; margin-bottom: 17px; }
  .login-archive-motif i { width: 45px; height: 27px; border-radius: 7px; }
  .login-archive-motif i:nth-child(1) { left: 12px; }
  .login-archive-motif i:nth-child(2) { top: 6px; left: 6px; }
  .login-archive-motif i:nth-child(3) { top: 12px; }
  .login-kicker { font-size: 10px; }
  .login-identity h1 { margin-top: 8px; font-size: 28px; }
  .login-identity > p { margin-top: 7px; font-size: 13px; }
  .login-index { display: none; }
  .login-access-panel { max-width: 430px; margin: 26px auto 0; padding: 23px; border-radius: 16px; }
  .login-copy { margin-bottom: 21px; }
  .login-copy h2 { font-size: 23px; }
  .share-access-panel { padding: 27px 21px; }
  .shared-view-head { padding: 0 11px; }
  .share-security { display: none; }
}

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

@keyframes notice-out { to { opacity: 0; } }
@keyframes popover-in { from { opacity: 0; transform: translateY(-2px); } }
@keyframes sheet-in { from { opacity: 0; transform: translateY(6px); } }
@keyframes modal-in { from { opacity: 0; transform: translateY(4px); } }
@keyframes modal-out { to { opacity: 0; transform: translateY(3px); } }
@keyframes backdrop-in { from { opacity: 0; } }
@keyframes backdrop-out { to { opacity: 0; } }

/* 主题切换圆形扩散：新快照做 clip-path 圆形揭示（圆心/半径经 CSS 变量注入），
   与站内文档查看器、管理端共用同一套机制；WAAPI 在 JS 侧作为高优先级双保险 */
@keyframes mg-theme-reveal {
  from { clip-path: circle(0px at var(--mg-reveal-x, 50%) var(--mg-reveal-y, 50%)); }
  to { clip-path: circle(var(--mg-reveal-r, 120vmax) at var(--mg-reveal-x, 50%) var(--mg-reveal-y, 50%)); }
}
::view-transition-image-pair(root) { isolation: auto; }
::view-transition-old(root) { animation: none; mix-blend-mode: normal; }
/* 过渡容器垫旧主题底色：旧快照瓦片被合成器丢弃时露出的洞与旧快照同色，闪烁不可察 */
::view-transition { background: var(--vt-under-bg, transparent); }
::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
html.vt-css-fallback::view-transition-new(root) { animation: mg-theme-reveal 800ms cubic-bezier(.4, 0, .2, 1) both; }
@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root),
  ::view-transition-new(root) { animation: none !important; }
}
