:root {
  color-scheme: light;
  --bg: #f3efe6;
  --panel: rgba(255, 252, 246, 0.92);
  --line: #d5c8b4;
  --text: #1e1a14;
  --muted: #645949;
  --accent: #0f6f62;
  --accent-strong: #094f45;
  --warn: #a14b16;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "PingFang SC", "Noto Serif SC", serif;
  background:
    radial-gradient(circle at top left, rgba(15, 111, 98, 0.14), transparent 26%),
    radial-gradient(circle at bottom right, rgba(161, 75, 22, 0.12), transparent 28%),
    linear-gradient(180deg, #faf5eb 0%, var(--bg) 100%);
}

.shell {
  max-width: 1560px;
  margin: 0 auto;
  padding: 36px 28px 60px;
}

.hero,
.panel,
.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 24px 60px rgba(30, 26, 20, 0.08);
}

.hero {
  display: grid;
  grid-template-columns: 1fr minmax(260px, 320px);
  gap: 20px;
  align-items: start;
  padding: 28px;
  border-radius: 28px;
}

.eyebrow {
  margin: 0 0 10px;
  letter-spacing: 0.16em;
  font-size: 12px;
  text-transform: uppercase;
  color: var(--accent);
}

h1,
h2,
h3 {
  margin: 0;
}

h1 {
  font-size: clamp(34px, 5vw, 58px);
  line-height: 1.02;
}

.sub,
.hint,
.user-card p {
  color: var(--muted);
}

.sub {
  margin: 14px 0 0;
  max-width: 700px;
  line-height: 1.7;
}

.user-card {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 18px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(15, 111, 98, 0.16);
}

.avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent), #77b7a0);
  color: white;
  font-size: 24px;
  font-weight: 700;
}

.panel {
  margin-top: 24px;
  border-radius: 24px;
  padding: 24px;
}

form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

label {
  display: grid;
  gap: 8px;
  font-size: 14px;
}

label span {
  color: var(--muted);
}

label.full,
.actions {
  grid-column: 1 / -1;
}

fieldset {
  margin: 0;
  border: 1px solid rgba(100, 89, 73, 0.18);
  border-radius: 20px;
  padding: 18px;
}

legend {
  padding: 0 8px;
  color: var(--muted);
}

input,
textarea,
button {
  font: inherit;
}

input,
textarea {
  width: 100%;
  border: 1px solid rgba(100, 89, 73, 0.22);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--text);
  padding: 14px 16px;
}

textarea {
  resize: vertical;
  min-height: 120px;
  line-height: 1.7;
}

.logic-box {
  min-height: 150px;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  background: rgba(255, 250, 241, 0.96);
}

.rule-guide-card {
  margin-bottom: 0;
}

.threshold-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

button,
.primary-link,
.ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 999px;
  padding: 12px 18px;
  text-decoration: none;
  transition: transform 160ms ease, background 160ms ease;
}

button,
.primary-link {
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: white;
  font-weight: 700;
  cursor: pointer;
}

button:hover,
.primary-link:hover,
.ghost-btn:hover {
  transform: translateY(-1px);
}

button:disabled {
  cursor: wait;
  opacity: 0.75;
}

.ghost-btn {
  background: transparent;
  border: 1px solid rgba(15, 111, 98, 0.18);
  color: var(--accent-strong);
}

.ghost-btn.small {
  padding: 8px 14px;
  font-size: 13px;
}

.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.inline-alert {
  margin: 0;
  color: #c63a32;
  font-size: 14px;
  line-height: 1.6;
  font-weight: 700;
}

.angle-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(240px, 1fr));
  gap: 18px;
  margin-top: 16px;
}

.angle-chip {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  min-height: 190px;
  padding: 18px 16px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(100, 89, 73, 0.14);
}

.angle-chip input {
  width: 18px;
  height: 18px;
  margin-top: 3px;
}

.angle-chip span {
  display: grid;
  gap: 10px;
}

.angle-chip strong {
  font-size: 16px;
  line-height: 1.45;
}

.angle-chip small {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.75;
}

.result-head,
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.badge {
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(15, 111, 98, 0.08);
  color: var(--accent);
  font-size: 13px;
}

.badge.subtle {
  background: rgba(15, 111, 98, 0.06);
}

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

.card {
  border: 1px solid rgba(100, 89, 73, 0.18);
  border-radius: 20px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.7);
}

.card h3 {
  margin-bottom: 12px;
  font-size: 18px;
}

.meta-list {
  display: grid;
  gap: 10px;
}

.meta-row {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 12px;
  line-height: 1.6;
}

.expert-list {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.rule-list {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.7;
}

.expert-card {
  padding: 16px;
  border: 1px solid rgba(100, 89, 73, 0.14);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.64);
}

.expert-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.expert-head h4,
.inner-card h4 {
  margin: 0;
}

.expert-meta,
.expert-example,
.draft-sub,
.empty-state {
  color: var(--muted);
  line-height: 1.6;
}

.draft-list {
  display: grid;
  gap: 20px;
  margin-top: 20px;
}

.draft-card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.74), rgba(248, 244, 236, 0.9));
}

.plain-draft-card {
  padding: 16px;
}

.plain-draft-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.plain-draft-text {
  display: grid;
  gap: 14px;
  line-height: 1.9;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(100, 89, 73, 0.18);
  border-radius: 18px;
  padding: 20px;
}

.plain-draft-line,
.plain-draft-body {
  font-size: 16px;
}

.plain-draft-line strong,
.plain-draft-body strong {
  font-weight: 700;
}

.plain-draft-title {
  font-size: 18px;
}

.plain-draft-paragraphs {
  margin-top: 8px;
}

.plain-draft-paragraphs p {
  margin: 0 0 1em;
}

.plain-draft-paragraphs p:last-child {
  margin-bottom: 0;
}

.draft-top,
.draft-actions {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.draft-grid {
  margin: 14px 0;
}

.inner-card {
  margin-top: 14px;
}

.inner-card textarea {
  min-height: auto;
}

iframe {
  width: 100%;
  min-height: 620px;
  border: 1px solid rgba(100, 89, 73, 0.18);
  border-radius: 18px;
  margin-top: 14px;
  background: white;
}

.warning,
.message {
  border-radius: 16px;
  padding: 14px 16px;
  line-height: 1.6;
}

.warning,
.message.warn {
  background: rgba(255, 239, 225, 0.92);
  border: 1px solid rgba(161, 75, 22, 0.18);
  color: var(--warn);
}

.message.ok {
  background: rgba(230, 250, 244, 0.9);
  border: 1px solid rgba(15, 111, 98, 0.18);
  color: var(--accent-strong);
}

.role-pill {
  display: inline-flex;
  width: fit-content;
  margin-top: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(15, 111, 98, 0.08);
  color: var(--accent-strong);
  font-size: 12px;
  text-transform: uppercase;
}

.login-body {
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(520px, 100%);
  border-radius: 28px;
  padding: 32px 28px;
}

.login-card .primary-link {
  margin-top: 18px;
}

.pending-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.user-table {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border: 1px solid rgba(100, 89, 73, 0.14);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
}

.user-row p {
  margin: 6px 0 0;
  color: var(--muted);
}

.user-row-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.role-select {
  min-width: 120px;
  padding: 10px 12px;
  border-radius: 999px;
  border: 1px solid rgba(100, 89, 73, 0.22);
  background: rgba(255, 255, 255, 0.92);
}

@media (max-width: 860px) {
  .hero,
  .grid,
  form,
  .angle-grid {
    grid-template-columns: 1fr;
  }

  .threshold-grid {
    grid-template-columns: 1fr;
  }

  .actions,
  .user-card,
  .result-head,
  .card-head,
  .draft-top,
  .expert-head,
  .user-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .meta-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1280px) {
  .angle-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
