.page-main {
  min-height: 100vh;
  margin-left: var(--rail-width);
  padding: calc(var(--header-height) + 38px) 38px 60px;
}

.page-heading {
  display: flex;
  max-width: 1240px;
  align-items: flex-end;
  justify-content: space-between;
  gap: 30px;
  margin: 0 auto 32px;
}

.page-heading > div > span,
.settings-panel header span {
  color: var(--accent-text);
  font-size: 9px;
  font-weight: 850;
  letter-spacing: 0.16em;
}

.page-heading h1 {
  margin: 7px 0 0;
  font-size: 30px;
  letter-spacing: -0.04em;
}

.page-heading p {
  max-width: 620px;
  margin: 11px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.page-notice {
  max-width: 1240px;
  margin: 17px auto 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.7;
}

.page-notice a {
  color: var(--accent-text);
}

.account-legal-links {
  margin: 14px 0 0;
}

.primary-link {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  padding: 0 14px;
  border-radius: 7px;
  color: white;
  background: var(--accent);
  font-size: 10px;
  font-weight: 780;
}

.history-summary {
  display: grid;
  max-width: 1240px;
  margin: 0 auto 16px;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.history-summary article,
.wallet-grid article {
  display: grid;
  min-height: 112px;
  align-content: center;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.history-summary span,
.wallet-grid span {
  color: var(--muted);
  font-size: 10px;
}

.history-summary strong,
.wallet-grid strong {
  margin-top: 8px;
  font-size: 27px;
  letter-spacing: -0.04em;
}

.history-panel {
  max-width: 1240px;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}

.history-panel > header {
  display: flex;
  min-height: 52px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
}

.history-panel h2 {
  margin: 0;
  font-size: 12px;
}

.history-panel header span {
  color: var(--muted);
  font-size: 9px;
}

.history-list {
  display: grid;
}

.history-list > .empty-message {
  padding: 18px 16px;
}

/* 作品行：缩略图 | 模型 + 提示词 | 规格 | 说明 | 状态 + 动作 */
.history-row {
  display: grid;
  min-height: 88px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  grid-template-columns: 72px minmax(150px, 1fr) 160px minmax(160px, 1fr) 200px;
  gap: 16px;
}

.history-thumb {
  display: grid;
  width: 72px;
  height: 72px;
  padding: 0;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  background: var(--surface-sunken);
  font-size: 11px;
  cursor: pointer;
}

/* 覆盖 .history-row button 的主色按钮样式：缩略图框始终是中性底 */
.history-row .history-thumb,
.history-row .history-thumb:disabled {
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--surface-sunken);
}

.history-thumb:disabled {
  cursor: default;
}

.history-thumb img,
.history-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.history-thumb[data-state="ready"]:hover {
  border-color: var(--accent);
}

.history-identity {
  min-width: 0;
}

.history-prompt {
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.history-actions {
  flex-wrap: wrap;
}

.history-row:last-child {
  border-bottom: 0;
}

.history-row > div {
  display: grid;
  gap: 5px;
}

.history-row strong {
  font-size: 11px;
}

.history-row code,
.history-row small,
.history-row p {
  margin: 0;
  color: var(--muted);
  font-size: 9px;
}

.history-row > p {
  line-height: 1.5;
}

.history-row > div:last-child {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
}

.status-pill {
  padding: 4px 7px;
  border-radius: 5px;
  color: var(--muted-strong);
  background: var(--surface-sunken);
  font-size: 9px;
  font-weight: 700;
}

.status-pill[data-state="ready"] {
  color: var(--success);
}

.status-pill[data-state="failed"],
.status-pill[data-state="rejected_output"],
.status-pill[data-state="cancelled"] {
  color: var(--danger);
}

.history-row button {
  min-height: 29px;
  padding: 0 9px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  color: white;
  background: var(--accent);
  font-size: 9px;
}

.preview-dialog {
  width: min(850px, calc(100vw - 32px));
}

.preview-dialog > img,
.preview-dialog > video {
  display: block;
  width: 100%;
  max-height: 70vh;
  object-fit: contain;
  background: var(--canvas-bg);
}

.preview-dialog > audio {
  display: block;
  width: calc(100% - 36px);
  margin: 26px 18px;
}

.preview-dialog > img[hidden],
.preview-dialog > video[hidden],
.preview-dialog > audio[hidden] {
  display: none;
}

.preview-dialog > footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 18px;
  color: var(--muted);
  font-size: 10px;
}

.preview-dialog > footer a {
  padding: 8px 11px;
  border-radius: 6px;
  color: white;
  background: var(--accent);
}

.demo-account {
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.1em;
}

.wallet-grid {
  display: grid;
  max-width: 1240px;
  margin: 0 auto 16px;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.wallet-grid small {
  margin-top: 8px;
  color: var(--muted);
  font-size: 9px;
}

.account-columns {
  display: grid;
  max-width: 1240px;
  margin: 0 auto;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.settings-panel {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.settings-panel > header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 18px;
}

.settings-panel h2 {
  margin: 5px 0 0;
  font-size: 17px;
}

.settings-panel header > i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
}

.settings-panel header > i.online {
  background: var(--success);
}

.settings-panel dl {
  margin: 0;
}

.settings-panel dl > div {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-top: 1px solid var(--line);
}

.settings-panel dt,
.settings-panel dd {
  margin: 0;
  font-size: 10px;
}

.settings-panel dt {
  color: var(--muted);
}

.security-list {
  display: grid;
  margin: 0 0 18px;
  padding: 0;
  gap: 10px;
  list-style: none;
}

.security-list li {
  padding-left: 13px;
  border-left: 2px solid var(--line-strong);
  color: var(--muted-strong);
  font-size: 10px;
  line-height: 1.55;
}

.account-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.account-status[data-state="signed-in"] {
  border-color: var(--success);
  color: var(--text);
}

a.secondary-action {
  display: inline-flex;
  align-items: center;
}

.settings-panel dl + .secondary-action {
  margin-top: 16px;
}

.secondary-action {
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--muted-strong);
  background: var(--surface-raised);
  font-size: 9px;
}

/* 账户页「登录密码」表单 */
.password-form {
  display: grid;
  gap: 12px;
}

.password-form label {
  display: grid;
  gap: 6px;
  color: var(--muted-strong);
  font-size: 12px;
  font-weight: 700;
}

.password-form label[hidden] {
  display: none;
}

.password-form input {
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  color: var(--text);
  background: var(--surface-raised);
  font-size: 14px;
}

.password-form input:focus {
  border-color: var(--accent);
  outline: none;
}

.password-form .form-error {
  margin: 0;
  padding: 9px 11px;
  border: 1px solid var(--danger-line);
  border-radius: 7px;
  color: var(--danger);
  background: var(--danger-soft);
  font-size: 12px;
}

.password-form .secondary-action {
  justify-self: start;
  font-size: 12px;
  font-weight: 700;
}
