:root {
  color-scheme: light;
  font-family: "Microsoft YaHei UI", "PingFang SC", "Noto Sans CJK SC", sans-serif;
  font-synthesis: none;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #18212f;
  --muted: #667085;
  --border: #d7dde5;
  --accent: #1677c8;
  --accent-dark: #0f5f9f;
  --accent-soft: #eaf4fb;
  --success: #18864b;
  --error: #c0392b;
  --warning: #d99000;
  --bee: #f4c430;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
}

button,
input {
  font: inherit;
}

button {
  touch-action: manipulation;
}

button:focus-visible,
input:focus-visible,
summary:focus-visible,
.file-picker:focus-within {
  outline: 3px solid rgba(22, 119, 200, 0.2);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.login-view {
  display: grid;
  min-height: 100dvh;
  place-items: center;
  padding: max(28px, env(safe-area-inset-top)) 22px max(28px, env(safe-area-inset-bottom));
  background: var(--surface);
}

.login-shell {
  width: min(100%, 390px);
}

.brand-lockup,
.mini-brand,
.result-heading {
  display: flex;
  align-items: center;
}

.brand-lockup {
  gap: 16px;
  margin-bottom: 42px;
}

.brand-mark {
  width: 68px;
  height: 68px;
  object-fit: cover;
  border: 1px solid #efd67c;
  border-radius: 8px;
  background: var(--bee);
}

.brand-lockup h1 {
  margin: 0 0 4px;
  font-size: 30px;
  line-height: 1.15;
}

.brand-lockup p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.login-form {
  display: grid;
  gap: 10px;
}

.input-label {
  margin-top: 8px;
  color: var(--text);
  font-size: 14px;
  font-weight: 650;
}

input[type="text"],
input[type="password"] {
  width: 100%;
  height: 50px;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 0 14px;
  color: var(--text);
  background: var(--surface);
  font-size: 16px;
  appearance: none;
}

.model-update-section {
  border-top: 1px solid #dbe8f3;
  padding: 24px 16px 28px;
  background:
    radial-gradient(circle at 100% 0, rgba(22, 119, 200, 0.1), transparent 42%),
    linear-gradient(180deg, #f7fbff 0%, #f3f7fb 100%);
}

.model-tool-card {
  overflow: hidden;
  border: 1px solid #cfe0ee;
  border-radius: 16px;
  background: #ffffff;
  box-shadow: 0 14px 34px rgba(35, 76, 112, 0.1);
}

.model-tool-hero {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 22px;
  background: linear-gradient(135deg, #f0f8ff 0%, #ffffff 62%, #f7fbff 100%);
}

.model-tool-icon {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border-radius: 15px;
  color: #ffffff;
  background: linear-gradient(145deg, #2089da, #0f65ad);
  box-shadow: 0 8px 18px rgba(22, 119, 200, 0.25);
}

.model-tool-icon svg,
.model-generate-icon svg,
.model-update-warning svg {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.model-tool-icon svg {
  width: 27px;
  height: 27px;
}

.model-tool-title {
  min-width: 0;
}

.model-tool-kicker {
  display: block;
  margin-bottom: 3px;
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.08em;
}

.model-tool-title h2 {
  margin: 0;
  color: #10253c;
  font-size: 21px;
  line-height: 1.25;
}

.model-tool-title p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.secure-pill {
  display: inline-flex;
  height: 30px;
  align-items: center;
  gap: 6px;
  border: 1px solid #b9e3cc;
  border-radius: 999px;
  padding: 0 10px;
  color: #157142;
  background: #effaf4;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.secure-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #1ba85b;
  box-shadow: 0 0 0 4px rgba(27, 168, 91, 0.12);
}

.model-process {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px minmax(0, 1fr) 34px minmax(0, 1fr);
  align-items: center;
  padding: 18px 22px;
  border-top: 1px solid #e4eef6;
  border-bottom: 1px solid #e4eef6;
  background: #fbfdff;
}

.model-process-step {
  display: grid;
  justify-items: center;
  text-align: center;
}

.model-process-step > span {
  display: grid;
  width: 27px;
  height: 27px;
  place-items: center;
  margin-bottom: 6px;
  border: 1px solid #b8d8ed;
  border-radius: 50%;
  color: var(--accent-dark);
  background: #eaf5fc;
  font-size: 12px;
  font-weight: 800;
}

.model-process-step strong {
  color: #20384f;
  font-size: 12px;
}

.model-process-step small {
  margin-top: 2px;
  color: #8493a3;
  font-size: 10px;
}

.model-process-line {
  height: 1px;
  margin-top: -25px;
  background: linear-gradient(90deg, #d7e8f4, #a9d2ec, #d7e8f4);
}

.model-update-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  padding: 22px 22px 8px;
}

.model-field {
  min-width: 0;
}

.model-field label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.model-field label span {
  color: #1c3248;
  font-size: 14px;
  font-weight: 750;
}

.model-field label small {
  color: #8997a5;
  font-size: 11px;
}

.model-input-wrap {
  display: flex;
  height: 54px;
  align-items: center;
  overflow: hidden;
  border: 1px solid #cbd9e5;
  border-radius: 11px;
  background: #fbfdff;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.model-input-wrap:focus-within {
  border-color: var(--accent);
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(22, 119, 200, 0.1);
}

.model-input-prefix {
  display: grid;
  width: 47px;
  height: 30px;
  flex: 0 0 47px;
  place-items: center;
  border-right: 1px solid #dbe6ee;
  color: #4f6f8a;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 12px;
  font-weight: 750;
}

.model-input-wrap input[type="text"] {
  height: 52px;
  min-width: 0;
  border: 0;
  border-radius: 0;
  padding: 0 14px;
  color: #152f46;
  background: transparent;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  outline: 0;
}

.model-inline-error {
  min-height: 0;
  margin: 5px 22px 0;
}

.model-generate-button {
  display: flex;
  width: calc(100% - 44px);
  min-height: 62px;
  align-items: center;
  justify-content: center;
  gap: 11px;
  margin: 13px 22px 0;
  border: 0;
  border-radius: 12px;
  padding: 8px 20px;
  color: #ffffff;
  background: linear-gradient(135deg, #1d86d5, #0d66ae);
  box-shadow: 0 9px 20px rgba(16, 103, 174, 0.22);
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease, opacity 150ms ease;
}

.model-generate-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(16, 103, 174, 0.27);
}

.model-generate-button:active {
  transform: translateY(0);
}

.model-generate-button:disabled {
  opacity: 0.62;
  cursor: default;
  transform: none;
}

.model-generate-icon {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  place-items: center;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.15);
}

.model-generate-icon svg {
  width: 20px;
  height: 20px;
}

.model-generate-button strong,
.model-generate-button small {
  display: block;
  text-align: left;
}

.model-generate-button strong {
  font-size: 15px;
}

.model-generate-button small {
  margin-top: 2px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 10px;
  font-weight: 500;
}

.model-update-status {
  min-height: 20px;
  margin: 8px 22px 0;
  color: var(--success);
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
}

.model-update-status.is-error {
  color: var(--error);
}

.model-update-warning {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: 7px 22px 20px;
  border-radius: 9px;
  padding: 10px 12px;
  color: #795600;
  background: #fff9e9;
  font-size: 11px;
  line-height: 1.55;
}

.model-update-warning svg {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  margin-top: 1px;
}

input:disabled {
  color: #98a2b3;
  background: #f2f4f7;
}

.password-wrap {
  position: relative;
}

.password-wrap input {
  padding-right: 54px;
}

.icon-button {
  display: inline-grid;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  place-items: center;
  border: 0;
  padding: 0;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.icon-button svg,
.file-picker svg,
.primary-button svg,
.secondary-button svg,
.success-mark svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.password-toggle {
  position: absolute;
  top: 3px;
  right: 3px;
}

.primary-button,
.secondary-button {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--accent);
  border-radius: 7px;
  padding: 0 18px;
  font-weight: 700;
  cursor: pointer;
}

.primary-button {
  color: white;
  background: var(--accent);
}

.primary-button:active {
  background: var(--accent-dark);
}

.primary-button:disabled {
  border-color: #b8c2cc;
  color: #ffffff;
  background: #b8c2cc;
  cursor: default;
}

.secondary-button {
  color: var(--accent-dark);
  background: var(--surface);
}

.full-button {
  width: 100%;
  margin-top: 22px;
}

.form-status,
.inline-error {
  min-height: 20px;
  margin: 2px 0 0;
  color: var(--error);
  font-size: 13px;
  line-height: 1.5;
}

.main-view {
  min-height: 100dvh;
  padding-bottom: calc(92px + var(--safe-bottom));
}

.app-header {
  position: sticky;
  z-index: 20;
  top: 0;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.96);
  padding-top: env(safe-area-inset-top);
  backdrop-filter: blur(12px);
}

.app-header-inner {
  display: flex;
  width: min(100%, 720px);
  height: 64px;
  align-items: center;
  justify-content: space-between;
  margin: 0 auto;
  padding: 0 16px;
}

.mini-brand {
  min-width: 0;
  gap: 10px;
}

.mini-brand img {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border-radius: 7px;
  object-fit: cover;
}

.mini-brand strong,
.mini-brand span {
  display: block;
}

.mini-brand strong {
  font-size: 18px;
  line-height: 1.2;
}

.mini-brand span {
  overflow: hidden;
  max-width: 150px;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-actions {
  display: flex;
}

.workspace {
  width: min(100%, 720px);
  margin: 0 auto;
}

.section-block {
  border-bottom: 1px solid var(--border);
  padding: 22px 16px;
  background: var(--surface);
}

.section-block + .section-block {
  margin-top: 10px;
  border-top: 1px solid var(--border);
}

.section-block h2,
.result-dialog h2 {
  margin: 0;
  font-size: 17px;
  line-height: 1.3;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.state-pill {
  display: inline-flex;
  min-width: 48px;
  height: 25px;
  align-items: center;
  justify-content: center;
  border: 1px solid #b7dfc8;
  border-radius: 999px;
  color: var(--success);
  background: #eef9f2;
  font-size: 12px;
}

.state-pill.is-offline {
  border-color: #f0c5bc;
  color: var(--error);
  background: #fff2ef;
}

.series-control {
  display: grid;
  overflow: hidden;
  height: 48px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: 7px;
}

.series-option {
  min-width: 0;
  border: 0;
  border-left: 1px solid var(--border);
  color: var(--muted);
  background: var(--surface);
  font-weight: 700;
  cursor: pointer;
}

.series-option:first-child {
  border-left: 0;
}

.series-option.is-selected {
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.file-picker {
  display: flex;
  min-height: 78px;
  align-items: center;
  gap: 14px;
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 14px;
  color: var(--accent-dark);
  background: var(--surface-soft);
  cursor: pointer;
}

.file-picker svg {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
}

.file-picker span {
  min-width: 0;
}

.file-picker strong,
.file-picker small {
  display: block;
}

.file-picker strong {
  overflow: hidden;
  color: var(--text);
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-picker small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.data-list,
.result-data {
  margin: 12px 0 0;
}

.data-list > div,
.result-data > div {
  display: grid;
  min-height: 46px;
  align-items: center;
  grid-template-columns: 108px minmax(0, 1fr);
  border-top: 1px solid #edf0f3;
}

.data-list > div:first-child,
.result-data > div:first-child {
  border-top: 0;
}

dt {
  color: var(--muted);
  font-size: 13px;
}

dd {
  overflow-wrap: anywhere;
  margin: 0;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 13px;
  font-weight: 650;
}

.text-button {
  min-height: 40px;
  border: 0;
  padding: 0 6px;
  color: var(--accent-dark);
  background: transparent;
  font-weight: 650;
  cursor: pointer;
}

.fields-list {
  margin-top: 12px;
  border-top: 1px solid #edf0f3;
}

.field-row {
  display: grid;
  min-height: 66px;
  align-items: center;
  grid-template-columns: 28px 104px minmax(0, 1fr);
  border-bottom: 1px solid #edf0f3;
  gap: 4px;
}

.field-row input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--accent);
}

.field-row label {
  font-size: 14px;
}

.field-row input[type="text"] {
  height: 42px;
  min-width: 0;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 14px;
}

.preview-details {
  border: 0;
}

.preview-details summary {
  display: flex;
  min-height: 42px;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  font-size: 17px;
  font-weight: 700;
  list-style: none;
}

.preview-details summary::-webkit-details-marker {
  display: none;
}

.summary-meta,
.preview-toolbar {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.preview-toolbar {
  display: flex;
  height: 38px;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  border-bottom: 1px solid var(--border);
}

.compact-icon {
  width: 38px;
  height: 38px;
  flex-basis: 38px;
}

#previewText {
  overflow: auto;
  max-height: 300px;
  margin: 0;
  padding: 14px 0 2px;
  color: var(--text);
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre;
}

.action-bar {
  position: fixed;
  z-index: 25;
  right: 0;
  bottom: 0;
  left: 0;
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.97);
  padding-bottom: var(--safe-bottom);
  backdrop-filter: blur(12px);
}

.action-bar-inner {
  display: grid;
  width: min(100%, 720px);
  min-height: 76px;
  align-items: center;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  margin: 0 auto;
  padding: 10px 16px;
}

.action-status {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.action-status span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
  background: #98a2b3;
}

.status-dot.is-ready {
  background: var(--success);
}

.status-dot.is-error {
  background: var(--error);
}

.generate-button {
  min-width: 132px;
}

.result-dialog {
  width: min(calc(100% - 24px), 480px);
  max-width: 480px;
  margin: auto auto 0;
  border: 0;
  border-radius: 8px 8px 0 0;
  padding: 14px 20px calc(18px + var(--safe-bottom));
  color: var(--text);
  background: var(--surface);
}

.result-dialog::backdrop {
  background: rgba(15, 23, 42, 0.46);
}

.result-handle {
  width: 38px;
  height: 4px;
  margin: 0 auto 20px;
  border-radius: 2px;
  background: #c5ccd5;
}

.result-heading {
  gap: 12px;
}

.result-heading p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.success-mark {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: var(--success);
}

.result-data {
  margin-top: 18px;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-soft);
}

.result-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.dialog-close {
  width: 100%;
  margin-top: 8px;
}

.model-result-dialog {
  overflow: auto;
  max-height: min(90dvh, 720px);
  border-radius: 18px 18px 0 0;
  padding: 16px 20px calc(20px + var(--safe-bottom));
}

.model-result-heading {
  padding: 0 2px;
}

.model-success-mark {
  width: 48px;
  height: 48px;
  flex-basis: 48px;
  background: linear-gradient(145deg, #27a767, #15864c);
  box-shadow: 0 8px 18px rgba(21, 134, 76, 0.2);
}

.model-result-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  margin-top: 20px;
  border: 1px solid #d8e6f0;
  border-radius: 12px;
  padding: 15px;
  background: linear-gradient(135deg, #f7fbff, #ffffff);
}

.model-result-summary > div:not(.model-result-arrow) {
  min-width: 0;
}

.model-result-summary span,
.model-result-summary strong {
  display: block;
}

.model-result-summary span {
  color: var(--muted);
  font-size: 11px;
}

.model-result-summary strong {
  overflow-wrap: anywhere;
  margin-top: 5px;
  color: #163752;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 18px;
}

.model-result-arrow {
  color: #7fa7c4;
  font-size: 22px;
}

.model-result-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 12px;
}

.model-result-checks span {
  border: 1px solid #cbe9d8;
  border-radius: 999px;
  padding: 5px 9px;
  color: #187146;
  background: #f1faf5;
  font-size: 10px;
  font-weight: 650;
}

.model-result-technical {
  margin-top: 14px;
  border-top: 1px solid #e5ebf0;
}

.model-result-technical summary {
  padding: 12px 2px 4px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.model-result-technical .result-data {
  margin-top: 8px;
}

.toast {
  position: fixed;
  z-index: 80;
  right: 18px;
  bottom: calc(98px + var(--safe-bottom));
  left: 18px;
  max-width: 420px;
  margin: 0 auto;
  border-radius: 7px;
  padding: 12px 14px;
  color: white;
  background: #253346;
  font-size: 13px;
  line-height: 1.4;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (min-width: 721px) {
  .workspace {
    margin-top: 18px;
    margin-bottom: 18px;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background: var(--surface);
  }

  .section-block + .section-block {
    margin-top: 0;
    border-top: 0;
  }

  .result-dialog {
    margin: auto;
    border-radius: 8px;
  }

  .model-result-dialog {
    border-radius: 18px;
  }
}

@media (max-width: 480px) {
  .field-row {
    grid-template-columns: 26px 92px minmax(0, 1fr);
  }

  .generate-button {
    min-width: 122px;
    padding-right: 13px;
    padding-left: 13px;
  }

  .model-update-section {
    padding: 18px 12px 24px;
  }

  .model-tool-card {
    border-radius: 14px;
  }

  .model-tool-hero {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 12px;
    padding: 18px 16px;
  }

  .model-tool-icon {
    width: 46px;
    height: 46px;
    border-radius: 13px;
  }

  .model-tool-title h2 {
    font-size: 19px;
  }

  .model-tool-title p {
    font-size: 12px;
  }

  .secure-pill {
    width: max-content;
    height: 26px;
    grid-column: 2;
    margin-top: -4px;
    font-size: 11px;
  }

  .model-process {
    grid-template-columns: minmax(0, 1fr) 18px minmax(0, 1fr) 18px minmax(0, 1fr);
    padding: 16px 10px;
  }

  .model-process-step small {
    display: none;
  }

  .model-process-line {
    margin-top: -18px;
  }

  .model-update-form {
    grid-template-columns: 1fr;
    gap: 15px;
    padding: 19px 16px 7px;
  }

  .model-inline-error {
    margin-right: 16px;
    margin-left: 16px;
  }

  .model-generate-button {
    width: calc(100% - 32px);
    margin-right: 16px;
    margin-left: 16px;
  }

  .model-update-status {
    margin-right: 16px;
    margin-left: 16px;
  }

  .model-update-warning {
    margin-right: 16px;
    margin-bottom: 16px;
    margin-left: 16px;
  }

  .model-result-summary strong {
    font-size: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
