/* ============================================================
   SOLARA · 曦图 — design foundation
   ============================================================ */
:root {
  --bg: #fbf7f1;
  --bg-deep: #f5ede2;
  --bg-warm: #fdf9f3;
  --surface: #ffffff;
  --surface-soft: #fffcf8;
  --surface-tint: #fff6ec;
  --ink: #211812;
  --ink-soft: #6d5d51;
  --ink-muted: #a29487;
  --ink-faint: #c3b6a9;
  --line: #ece1d5;
  --line-strong: #dfd0c0;
  --orange: #f26b1d;
  --orange-bright: #f8842f;
  --orange-deep: #d9510a;
  --orange-ink: #a43c06;
  --orange-soft: #fff0e3;
  --orange-pale: #fff7ef;
  --peach: #f7cfac;
  --sand: #ead3b7;
  --cream: #fff8ee;
  --espresso: #211510;
  --umber: #3a2418;
  --green: #2f7d54;
  --green-soft: #e9f5ed;
  --red: #b84225;
  --red-soft: #fbece6;
  --amber: #a96b09;
  --amber-soft: #fff4d9;
  --radius-xs: 8px;
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-xl: 28px;
  --radius-pill: 999px;
  --shadow-xs: 0 1px 2px rgba(51, 32, 18, 0.04);
  --shadow-sm: 0 6px 18px -12px rgba(51, 32, 18, 0.24);
  --shadow-md: 0 18px 44px -28px rgba(51, 32, 18, 0.34);
  --shadow-lg: 0 38px 90px -48px rgba(51, 32, 18, 0.44);
  --font-sans: "Inter", "Segoe UI Variable", "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC",
    "Hiragino Sans GB", sans-serif;
  --font-display: "Georgia", "Times New Roman", "Songti SC", "SimSun", serif;
  --font-cn-serif: "Noto Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --font-mono: "SFMono-Regular", "Cascadia Mono", "Consolas", monospace;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-soft: cubic-bezier(0.4, 0, 0.2, 1);
  --sidebar-width: 246px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body.no-scroll {
  overflow: hidden;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  border: 0;
  background: none;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  display: block;
  max-width: 100%;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

ul,
ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

[hidden] {
  display: none !important;
}

::selection {
  background: var(--orange);
  color: var(--cream);
}

:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 3px;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #ddcdbc;
  border: 3px solid var(--bg);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: #c7b5a3;
}

.icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  display: inline-block;
  vertical-align: -0.15em;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 1000;
  transform: translateY(-160%);
  background: var(--ink);
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  transition: transform 0.2s var(--ease-out);
}

.skip-link:focus {
  transform: translateY(0);
}

/* ---------------------------------- brand --------------------------------- */

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  line-height: 1;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: linear-gradient(140deg, #f99345 0%, #f26b1d 48%, #d9510a 100%);
  box-shadow: 0 7px 16px -9px rgba(217, 81, 10, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
}

.brand-mark svg {
  width: 28px;
  height: 28px;
}

.brand-type {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.brand-name {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.24em;
  color: var(--ink);
  padding-left: 1px;
}

.brand-cn {
  font-size: 8.5px;
  letter-spacing: 0.38em;
  color: var(--ink-muted);
  font-weight: 500;
}

.brand--light .brand-name {
  color: #fff7ee;
}

.brand--light .brand-cn {
  color: rgba(255, 247, 238, 0.5);
}

/* --------------------------------- typography ------------------------------ */

.display {
  font-family: var(--font-cn-serif);
  font-weight: 600;
  letter-spacing: -0.035em;
  line-height: 1.05;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.eyebrow::before {
  content: "";
  width: 26px;
  height: 1px;
  background: var(--orange);
  flex: 0 0 auto;
}

.eyebrow--plain::before {
  display: none;
}

.eyebrow--light {
  color: rgba(255, 247, 238, 0.55);
}

.eyebrow--light::before {
  background: #f8842f;
}

.serif {
  font-family: var(--font-display);
}

.muted {
  color: var(--ink-muted);
}

.mono {
  font-family: var(--font-mono);
}

/* ---------------------------------- buttons -------------------------------- */

.btn {
  --btn-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  height: var(--btn-height);
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: 13px;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  transition:
    transform 0.22s var(--ease-out),
    background 0.22s var(--ease-soft),
    border-color 0.22s var(--ease-soft),
    box-shadow 0.22s var(--ease-soft),
    color 0.22s var(--ease-soft);
}

.btn .icon {
  width: 17px;
  height: 17px;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.58;
  transform: none !important;
}

.btn-primary {
  background: linear-gradient(135deg, #f88734 0%, #f26b1d 45%, #e55a0d 100%);
  color: #fffaf4;
  box-shadow:
    0 14px 26px -16px rgba(217, 81, 10, 0.78),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.btn-primary:hover {
  box-shadow:
    0 18px 32px -16px rgba(217, 81, 10, 0.8),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
  filter: saturate(1.04);
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
  box-shadow: var(--shadow-xs);
}

.btn-secondary:hover {
  border-color: var(--line-strong);
  background: var(--surface-soft);
}

.btn-ghost {
  color: var(--ink-soft);
  background: transparent;
}

.btn-ghost:hover {
  background: rgba(58, 36, 24, 0.055);
  color: var(--ink);
}

.btn-danger {
  background: var(--red-soft);
  color: var(--red);
  border-color: #f3d5c9;
}

.btn-danger:hover {
  background: #f9e2d9;
}

.btn-dark {
  background: var(--espresso);
  color: var(--cream);
}

.btn-dark:hover {
  background: #302018;
}

.btn-sm {
  --btn-height: 34px;
  padding: 0 12px;
  border-radius: 9px;
  font-size: 12px;
  gap: 6px;
}

.btn-lg {
  --btn-height: 52px;
  padding: 0 26px;
  border-radius: 15px;
  font-size: 14.5px;
}

.btn-block {
  width: 100%;
}

.btn-text {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--orange-deep);
  font-size: 12.5px;
  font-weight: 600;
  padding: 4px 0;
  transition: gap 0.2s var(--ease-out), color 0.2s;
}

.btn-text:hover {
  gap: 9px;
  color: var(--orange-ink);
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: inline-grid;
  place-items: center;
  color: var(--ink-soft);
  border: 1px solid transparent;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.icon-btn:hover {
  background: var(--surface-tint);
  color: var(--ink);
  border-color: var(--line);
}

.icon-btn .icon {
  width: 18px;
  height: 18px;
}

.icon-btn--danger:hover {
  background: var(--red-soft);
  color: var(--red);
  border-color: #f3d5c9;
}

/* ---------------------------------- forms ---------------------------------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
}

.field-label .optional {
  font-weight: 500;
  color: var(--ink-faint);
  letter-spacing: 0;
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrap > .icon {
  position: absolute;
  left: 15px;
  width: 17px;
  height: 17px;
  color: var(--ink-faint);
  pointer-events: none;
  transition: color 0.2s;
}

.input-wrap:focus-within > .icon {
  color: var(--orange);
}

.input,
.textarea,
.select {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  border-radius: 12px;
  padding: 0 14px;
  height: 46px;
  color: var(--ink);
  font-size: 13.5px;
  transition:
    border-color 0.2s var(--ease-soft),
    background 0.2s var(--ease-soft),
    box-shadow 0.2s var(--ease-soft);
}

.input-wrap .input {
  padding-left: 43px;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--ink-faint);
}

.input:hover,
.textarea:hover {
  border-color: var(--line-strong);
}

.input:focus,
.textarea:focus,
.select:focus {
  outline: none;
  border-color: #f3a56c;
  background: #fff;
  box-shadow: 0 0 0 3.5px rgba(242, 107, 29, 0.1);
}

.input[disabled],
.textarea[disabled] {
  background: #f4ede5;
  color: var(--ink-muted);
  cursor: not-allowed;
}

.textarea {
  height: auto;
  min-height: 128px;
  padding: 13px 14px;
  line-height: 1.65;
  resize: vertical;
}

.select {
  appearance: none;
  padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238e7e71' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  cursor: pointer;
}

.input-suffix-btn {
  position: absolute;
  right: 7px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--ink-faint);
}

.input-suffix-btn:hover {
  background: rgba(58, 36, 24, 0.06);
  color: var(--ink-soft);
}

.field-help {
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--ink-muted);
}

.field-help strong {
  color: var(--ink-soft);
  font-weight: 600;
}

.form-error {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: var(--red-soft);
  color: #9f3a20;
  border: 1px solid #f3d5c9;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12.5px;
  line-height: 1.5;
  animation: shake-in 0.35s var(--ease-out);
}

.form-error .icon {
  margin-top: 1px;
  width: 15px;
  height: 15px;
}

.form-success {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--green-soft);
  color: var(--green);
  border: 1px solid #cfe7d8;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12.5px;
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 12.5px;
  color: var(--ink-soft);
  cursor: pointer;
  user-select: none;
}

.checkbox input {
  width: 15px;
  height: 15px;
  accent-color: var(--orange);
  margin: 0;
}

/* switch */
.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  flex: 0 0 auto;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-track {
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: #ddcfc2;
  transition: background 0.22s var(--ease-soft);
  position: relative;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(33, 24, 18, 0.22);
  transition: transform 0.22s var(--ease-out);
}

.switch input:checked + .switch-track {
  background: var(--orange);
}

.switch input:checked + .switch-track::after {
  transform: translateX(18px);
}

.switch input:focus-visible + .switch-track {
  outline: 2px solid var(--orange);
  outline-offset: 3px;
}

/* ---------------------------------- badges --------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 23px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.badge .icon {
  width: 12px;
  height: 12px;
}

.badge-orange {
  background: var(--orange-soft);
  color: var(--orange-deep);
}

.badge-green {
  background: var(--green-soft);
  color: var(--green);
}

.badge-red {
  background: var(--red-soft);
  color: var(--red);
}

.badge-amber {
  background: var(--amber-soft);
  color: var(--amber);
}

.badge-muted {
  background: #f1eae2;
  color: var(--ink-muted);
}

.badge-dark {
  background: rgba(33, 21, 16, 0.9);
  color: var(--cream);
}

/* ---------------------------------- avatar --------------------------------- */

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  background: linear-gradient(145deg, #f8c49a, #ef853c);
  color: #fffdf9;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  flex: 0 0 auto;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
  text-transform: uppercase;
}

.avatar--sm {
  width: 30px;
  height: 30px;
  font-size: 12px;
}

.avatar--lg {
  width: 52px;
  height: 52px;
  font-size: 19px;
}

/* ---------------------------------- toast ---------------------------------- */

.toast-stack {
  position: fixed;
  top: 22px;
  right: 22px;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(380px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 13px 15px;
  border-radius: 13px;
  background: rgba(33, 21, 16, 0.96);
  color: #fff8f0;
  box-shadow: 0 22px 44px -22px rgba(33, 21, 16, 0.7);
  font-size: 12.5px;
  line-height: 1.55;
  pointer-events: auto;
  animation: toast-in 0.35s var(--ease-out);
  backdrop-filter: blur(12px);
}

.toast .icon {
  width: 17px;
  height: 17px;
  margin-top: 1px;
}

.toast--success .icon {
  color: #f8b477;
}

.toast--error {
  background: rgba(110, 34, 16, 0.97);
}

.toast--error .icon {
  color: #ffc9b5;
}

.toast--info .icon {
  color: #f8832f;
}

.toast.is-leaving {
  animation: toast-out 0.25s var(--ease-soft) forwards;
}

/* ---------------------------------- modal ---------------------------------- */

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: grid;
  place-items: center;
  padding: 24px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(27, 17, 11, 0.5);
  backdrop-filter: blur(5px);
  animation: fade-in 0.25s var(--ease-soft);
}

.modal-card {
  position: relative;
  width: min(460px, 100%);
  max-height: min(86vh, 780px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 22px;
  box-shadow: 0 50px 110px -40px rgba(33, 21, 16, 0.65);
  padding: 28px;
  animation: modal-in 0.34s var(--ease-out);
}

.modal-card--wide {
  width: min(620px, 100%);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.modal-head h3 {
  font-family: var(--font-cn-serif);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.modal-head p {
  margin-top: 6px;
  color: var(--ink-muted);
  font-size: 12.5px;
  line-height: 1.6;
}

.modal-close {
  margin: -7px -7px 0 0;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 24px;
}

.modal-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-note {
  display: flex;
  gap: 9px;
  padding: 12px;
  border-radius: 11px;
  background: var(--surface-tint);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.6;
}

.modal-note .icon {
  color: var(--orange);
  margin-top: 1px;
}

/* --------------------------------- spinner --------------------------------- */

.spinner {
  width: 16px;
  height: 16px;
  border: 1.8px solid rgba(255, 255, 255, 0.35);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: rotate 0.75s linear infinite;
}

.spinner--dark {
  border-color: rgba(33, 21, 16, 0.15);
  border-top-color: var(--orange);
}

/* --------------------------------- states ---------------------------------- */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 54px 24px;
  gap: 14px;
  color: var(--ink-muted);
}

.empty-icon {
  width: 58px;
  height: 58px;
  border-radius: 18px;
  background: var(--orange-pale);
  color: var(--orange);
  display: grid;
  place-items: center;
  border: 1px solid #f7dfcb;
}

.empty-icon .icon {
  width: 24px;
  height: 24px;
}

.empty-state h3 {
  color: var(--ink);
  font-family: var(--font-cn-serif);
  font-size: 18px;
  font-weight: 600;
}

.empty-state p {
  font-size: 12.5px;
  max-width: 340px;
  line-height: 1.7;
}

/* --------------------------------- utilities ------------------------------- */

.divider {
  height: 1px;
  background: var(--line);
  border: 0;
  margin: 0;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
  flex: 0 0 auto;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 27px;
  padding: 0 11px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-soft);
}

.status-pill .dot {
  width: 6px;
  height: 6px;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(47, 125, 84, 0.12);
}

.status-pill--warn .dot {
  background: var(--amber);
  box-shadow: 0 0 0 3px rgba(169, 107, 9, 0.12);
}

.status-pill--off .dot {
  background: var(--ink-faint);
  box-shadow: none;
}

.grain::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.22;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.28'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}

/* -------------------------------- animations ------------------------------- */

@keyframes rotate {
  to {
    transform: rotate(360deg);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-8px) translateX(10px);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateX(16px);
  }
}

@keyframes shake-in {
  from {
    opacity: 0;
    transform: translateY(-3px);
  }
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes soft-pulse {
  0%,
  100% {
    opacity: 0.55;
  }
  50% {
    opacity: 1;
  }
}

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

@media (max-width: 640px) {
  .modal-root {
    padding: 0;
    align-items: end;
  }

  .modal-card,
  .modal-card--wide {
    width: 100%;
    max-height: 92vh;
    border-radius: 22px 22px 0 0;
    padding: 24px 20px 28px;
  }

  .modal-actions {
    position: sticky;
    bottom: -28px;
    background: var(--surface);
    padding: 12px 0;
    margin-top: 16px;
  }

  .toast-stack {
    top: 12px;
    right: 12px;
    width: calc(100vw - 24px);
  }
}
