* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    repeating-linear-gradient(92deg, color-mix(in oklch, var(--primary) 4%, transparent) 0 1px, transparent 1px 34px),
    radial-gradient(circle at 56% 0%, color-mix(in oklch, var(--glow) 13%, transparent), transparent 28%),
    var(--paper);
  font-family: var(--font-ui);
  letter-spacing: 0;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 16% 12%, color-mix(in oklch, var(--surface) 70%, transparent), transparent 24%);
  opacity: .72;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
select {
  -webkit-tap-highlight-color: transparent;
}

button {
  text-align: center;
}

h1,
h2,
.brand-lockup strong {
  text-wrap: balance;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.kicker,
.section-label {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 14px;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.login-screen {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  width: min(1180px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(440px, 1fr) 360px;
  gap: clamp(44px, 8vw, 120px);
  align-items: center;
  padding: clamp(32px, 7vw, 92px);
}

.login-copy h1 {
  margin: var(--space-4) 0 var(--space-3);
  font-family: var(--font-display);
  width: max-content;
  max-width: 100%;
  font-size: clamp(56px, 8vw, 96px);
  line-height: .94;
  letter-spacing: 0;
  white-space: nowrap;
}

.login-copy p:not(.kicker) {
  max-width: 520px;
  margin: 0;
  color: color-mix(in oklch, var(--ink) 68%, var(--paper));
  font-size: 18px;
  line-height: 30px;
}

.panel,
.login-card,
.modal-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: color-mix(in oklch, var(--surface) 96%, transparent);
  box-shadow: var(--shadow-soft);
}

.login-card {
  display: grid;
  gap: var(--space-4);
  padding: var(--space-6);
}

.login-card h2,
.panel h2,
.modal-card h2 {
  margin: var(--space-1) 0 0;
  font-size: 24px;
  line-height: 31px;
  letter-spacing: 0;
}

.login-card label,
.modal-field,
.field-label {
  display: grid;
  gap: var(--space-2);
  color: var(--muted);
  font-size: 12px;
  line-height: 16px;
}

input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--ink);
  outline: none;
}

input,
select {
  height: 42px;
  padding: 0 var(--space-4);
}

textarea {
  padding: var(--space-4);
  resize: vertical;
  font-family: var(--font-paper);
  line-height: 28px;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  border-color: var(--primary);
  outline: 3px solid color-mix(in oklch, var(--primary) 18%, transparent);
}

.app-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--rail-width, 260px) minmax(0, 1fr);
  transition: grid-template-columns var(--motion-mid) var(--ease-out);
}

.app-shell.rail-collapsed {
  --rail-width: 56px;
}

.side-rail {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  min-width: 0;
  overflow: hidden;
  padding: 16px 8px;
  background: color-mix(in oklch, var(--rail) 94%, var(--surface));
  border-right: 1px solid var(--line);
}

.rail-brand {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 48px;
  padding: 0 var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--line);
}

.logo-mark {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, var(--primary), var(--primary-2));
  color: var(--surface);
  font-family: var(--font-number);
  font-weight: 900;
}

.rail-brand strong,
.rail-brand small {
  display: block;
  white-space: nowrap;
}

.rail-brand small {
  color: var(--muted);
  font-size: 12px;
}

.rail-toggle {
  width: 28px;
  height: 28px;
  margin-left: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: color-mix(in oklch, var(--surface) 88%, transparent);
  color: var(--muted);
  cursor: pointer;
  transition: transform var(--motion-fast) var(--ease-out), background var(--motion-fast) var(--ease-out), border var(--motion-fast) var(--ease-out);
}

.rail-toggle::before {
  content: "";
  width: 15px;
  height: 15px;
  display: block;
  margin: auto;
  background: currentColor;
  clip-path: polygon(72% 15%, 82% 25%, 47% 50%, 82% 75%, 72% 85%, 28% 50%);
}

.rail-toggle:hover {
  border-color: color-mix(in oklch, var(--primary) 28%, var(--line));
  background: var(--surface);
  transform: translateY(-1px);
}

.rail-nav {
  display: grid;
  gap: var(--space-2);
}

.rail-nav button {
  width: 100%;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0 var(--space-3);
  cursor: pointer;
  font-weight: 850;
  transition: transform var(--motion-fast) var(--ease-out), background var(--motion-fast) var(--ease-out);
}

.rail-nav button:hover {
  transform: translateY(-1px);
  background: color-mix(in oklch, var(--primary-soft) 70%, transparent);
}

.rail-nav button.active {
  border-color: color-mix(in oklch, var(--primary) 20%, var(--line));
  background: var(--primary-soft);
  color: var(--primary-text);
}

.rail-system {
  margin-top: auto;
  display: grid;
  gap: var(--space-2);
  padding-top: var(--space-3);
  border-top: 1px solid color-mix(in oklch, var(--line) 72%, transparent);
}

.system-link,
.account-card {
  width: 100%;
  border: 1px solid transparent;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.system-link {
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  border-radius: var(--radius-md);
  background: transparent;
  padding: 0 var(--space-3);
  font-weight: 850;
  transition: transform var(--motion-fast) var(--ease-out), background var(--motion-fast) var(--ease-out);
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  display: inline-grid;
  place-items: center;
}

.nav-icon::before {
  content: "";
  width: 18px;
  height: 18px;
  background: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat;
  mask: var(--icon) center / contain no-repeat;
}

.icon-new {
  --icon: url("data:image/svg+xml,%3Csvg width='24' height='24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M7 3.5h7l3 3v14H7z'/%3E%3Cpath d='M14 3.5v4h4'/%3E%3Cpath d='M12 11v6M9 14h6'/%3E%3C/svg%3E");
}

.icon-folder {
  --icon: url("data:image/svg+xml,%3Csvg width='24' height='24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3.5 6.5h6l2 2h10v10.8a1.2 1.2 0 0 1-1.2 1.2H4.7a1.2 1.2 0 0 1-1.2-1.2z'/%3E%3Cpath d='M3.5 9h18'/%3E%3C/svg%3E");
}

.icon-material {
  --icon: url("data:image/svg+xml,%3Csvg width='24' height='24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5 4.5h14v15H5z'/%3E%3Cpath d='M8 8h8M8 11.5h8M8 15h5'/%3E%3Cpath d='M17 4.5v15' opacity='.45'/%3E%3C/svg%3E");
}

.icon-shield {
  --icon: url("data:image/svg+xml,%3Csvg width='24' height='24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 3.5 19 6v5.4c0 4.2-2.8 7.2-7 9.1-4.2-1.9-7-4.9-7-9.1V6z'/%3E%3Cpath d='m9.2 12 1.9 1.9 4-4.2'/%3E%3C/svg%3E");
}

.icon-gear {
  --icon: url("data:image/svg+xml,%3Csvg width='24' height='24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 8.2a3.8 3.8 0 1 0 0 7.6 3.8 3.8 0 0 0 0-7.6Z'/%3E%3Cpath d='M19 13.2v-2.4l-2.1-.6a7 7 0 0 0-.8-1.8l1.1-1.9-1.7-1.7-1.9 1.1a7 7 0 0 0-1.8-.8L11.2 3H8.8l-.6 2.1a7 7 0 0 0-1.8.8L4.5 4.8 2.8 6.5l1.1 1.9a7 7 0 0 0-.8 1.8l-2.1.6v2.4l2.1.6a7 7 0 0 0 .8 1.8l-1.1 1.9 1.7 1.7 1.9-1.1a7 7 0 0 0 1.8.8l.6 2.1h2.4l.6-2.1a7 7 0 0 0 1.8-.8l1.9 1.1 1.7-1.7-1.1-1.9a7 7 0 0 0 .8-1.8z'/%3E%3C/svg%3E");
}

.nav-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.system-link:hover {
  transform: translateY(-1px);
  background: color-mix(in oklch, var(--primary-soft) 70%, transparent);
}

.system-link.active {
  border-color: color-mix(in oklch, var(--primary) 20%, var(--line));
  background: var(--primary-soft);
  color: var(--primary-text);
}

.account-card {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: center;
  gap: var(--space-2);
  width: min(100%, 228px);
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: color-mix(in oklch, var(--surface) 62%, transparent);
  transition: transform var(--motion-fast) var(--ease-out), box-shadow var(--motion-fast) var(--ease-out), border var(--motion-fast) var(--ease-out);
}

.account-card:hover {
  transform: translateY(-1px);
  border-color: color-mix(in oklch, var(--primary) 24%, var(--line));
  box-shadow: var(--shadow-hover);
}

.account-card.active {
  border-color: color-mix(in oklch, var(--primary) 24%, var(--line));
  background: color-mix(in oklch, var(--primary-soft) 72%, var(--surface));
}

.account-avatar {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--surface);
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  font-weight: 900;
  font-size: 13px;
}

.account-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.account-copy small,
.account-copy em {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.account-copy strong {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 15px;
  line-height: 20px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-shell.rail-collapsed .rail-brand {
  justify-content: center;
  padding-inline: 0;
}

.app-shell.rail-collapsed .rail-brand div,
.app-shell.rail-collapsed .nav-text,
.app-shell.rail-collapsed .account-copy {
  display: none;
}

.app-shell.rail-collapsed .logo-mark {
  display: none;
}

.app-shell.rail-collapsed .rail-toggle {
  margin: 0;
  transform: rotate(180deg);
}

.app-shell.rail-collapsed .rail-nav button,
.app-shell.rail-collapsed .system-link {
  justify-content: center;
  padding: 0;
}

.app-shell.rail-collapsed .account-card {
  grid-template-columns: 1fr;
  place-items: center;
  padding: var(--space-2);
}

.workspace {
  min-width: 0;
  display: grid;
  grid-template-rows: 62px minmax(0, 1fr);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: 0 26px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in oklch, var(--paper) 92%, transparent);
  backdrop-filter: blur(10px);
}

.brand-lockup,
.top-actions {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.brand-lockup {
  display: grid;
  gap: 2px;
}

.brand-lockup strong,
.brand-lockup span {
  display: block;
}

.brand-lockup span {
  color: var(--muted);
  font-size: 12px;
}

.theme-picker {
  display: flex;
  gap: 7px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}

.theme-picker button {
  width: 18px;
  height: 18px;
  border: 1px solid var(--line);
  border-radius: 50%;
  cursor: pointer;
}

.theme-picker button:nth-child(1) { background: #12754d; }
.theme-picker button:nth-child(2) { background: #2a6f86; }
.theme-picker button:nth-child(3) { background: #6c5978; }
.theme-picker button:nth-child(4) { background: #5f7556; }

.theme-picker button.active {
  outline: 2px solid color-mix(in oklch, var(--primary) 28%, transparent);
  outline-offset: 2px;
}

.chip {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--muted);
  padding: 0 var(--space-3);
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.chip.strong,
.button-chip {
  background: var(--primary-soft);
  color: var(--primary-text);
}

.button-chip {
  min-width: auto;
  cursor: pointer;
}

.view {
  display: none;
  min-width: 0;
  min-height: calc(100vh - 62px);
  padding: var(--space-5);
}

.view.active {
  display: block;
}

.button {
  min-width: var(--button-min);
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0 var(--space-4);
  cursor: pointer;
  font-weight: 850;
  line-height: 1;
  transition: transform var(--motion-fast) var(--ease-out), box-shadow var(--motion-fast) var(--ease-out), background var(--motion-fast) var(--ease-out);
}

.button.small {
  min-width: 92px;
  min-height: 36px;
  padding: 0 var(--space-3);
  font-size: 12px;
}

.button.wide {
  width: 100%;
}

.button:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-hover);
}

.button:active {
  transform: translateY(1px);
}

.button.filled {
  border-color: transparent;
  color: var(--surface);
  background:
    radial-gradient(circle at 18% 10%, color-mix(in oklch, var(--glow) 44%, transparent), transparent 38%),
    linear-gradient(180deg, color-mix(in oklch, var(--primary) 94%, var(--surface)), var(--primary-2));
}

.button:disabled,
.button[aria-disabled="true"] {
  cursor: not-allowed;
  color: var(--disabled-text);
  background: var(--disabled-bg);
  box-shadow: none;
  transform: none;
}

.button.soft {
  border-color: transparent;
  background: var(--primary-soft);
  color: var(--primary-text);
}

.compact-actions,
.modal-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: var(--button-gap);
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 30;
  max-width: min(360px, calc(100vw - 44px));
  min-height: 44px;
  display: flex;
  align-items: center;
  border-radius: var(--radius-md);
  background: var(--primary);
  color: var(--surface);
  padding: 0 var(--space-4);
  box-shadow: var(--shadow-paper);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity var(--motion-mid) var(--ease-out), transform var(--motion-mid) var(--ease-out);
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: var(--space-4);
  background: rgb(16 38 29 / 22%);
  backdrop-filter: blur(8px);
}

.modal-card {
  position: relative;
  width: min(590px, 100%);
  display: grid;
  gap: var(--space-4);
  padding: var(--space-6);
  box-shadow: var(--shadow-paper);
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: 20px;
}

.modal-body p {
  margin: 0;
  color: color-mix(in oklch, var(--ink) 76%, var(--paper));
  line-height: 26px;
}

.modal-field {
  margin-top: var(--space-3);
}

.modal-field textarea {
  min-height: 138px;
}

.password-box {
  padding: var(--space-4);
  border: 1px dashed var(--primary);
  border-radius: var(--radius-md);
  background: var(--primary-soft);
  color: var(--primary-text);
  font-family: var(--font-number);
  font-size: 24px;
  font-weight: 900;
  text-align: center;
}

@media (max-width: 980px) {
  .login-screen,
  .app-shell {
    grid-template-columns: 1fr;
  }

  .side-rail {
    position: relative;
  }

  .topbar {
    display: grid;
    grid-template-columns: 1fr;
    align-content: start;
    min-height: auto;
    row-gap: var(--space-3);
    padding: var(--space-3);
  }

  .top-actions {
    flex-wrap: wrap;
  }

  .view {
    padding: var(--space-3);
  }
}

@media (max-width: 720px) {
  .login-copy h1 {
    font-size: clamp(54px, 18vw, 78px);
  }

  .compact-actions,
  .modal-actions {
    align-items: stretch;
  }

  .compact-actions .button,
  .modal-actions .button {
    flex: 1 1 140px;
  }
}

/* ===== 2026-06-05: 主画布去重标题 + 防横向溢出 ===== */
.app-shell {
  --rail-width: 228px;
}
.workspace {
  grid-template-rows: 50px minmax(0, 1fr);
  overflow-x: hidden;
}
.topbar {
  min-height: 50px;
  justify-content: flex-end;
  padding: 0 18px;
}
.brand-lockup {
  display: none !important;
}
.view {
  min-height: calc(100vh - 50px);
  padding: 14px 18px 18px;
  overflow-x: hidden;
}
.panel {
  max-width: 100%;
  overflow: hidden;
}
.logo-mark {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  font-size: 13px;
}
.rail-brand strong {
  font-size: 15px;
  line-height: 18px;
}
.rail-brand small {
  font-size: 11px;
  line-height: 14px;
}
.account-card {
  grid-template-columns: 24px minmax(0, 1fr);
  width: min(100%, 202px);
  padding: 8px;
  gap: 8px;
}
.account-avatar {
  width: 24px;
  height: 24px;
  font-size: 11px;
}
.account-copy small,
.account-copy em {
  font-size: 10px;
  line-height: 13px;
}
.account-copy strong {
  font-size: 13px;
  line-height: 17px;
}
