:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-strong: #111827;
  --text: #172033;
  --muted: #667085;
  --line: #d8deea;
  --accent: #ff4d6d;
  --accent-strong: #d91f4c;
  --amber: #ff9f1c;
  --blue: #2f6bff;
  --green: #00a878;
  --shadow: 0 22px 60px rgba(39, 53, 82, 0.12);
  --radius: 8px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--text);
  background: linear-gradient(135deg, #f9fbff 0%, var(--bg) 54%, #eef3ff 100%);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  min-height: 100svh;
  margin: 0 auto;
  padding: 28px 0;
}

.app-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 56px;
  line-height: 0.95;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
  line-height: 1.25;
  letter-spacing: 0;
}

.notice-banner {
  max-width: 320px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 159, 28, 0.42);
  border-radius: var(--radius);
  color: #7a4100;
  background: #fff4dc;
  font-size: 14px;
  font-weight: 700;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  gap: 20px;
  align-items: stretch;
}

.config-panel,
.wheel-stage,
.history-panel {
  border: 1px solid rgba(216, 222, 234, 0.86);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
}

.config-panel {
  padding: 22px;
}

.section-heading {
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
}

.section-heading p,
.wheel-topline p,
.field-hint,
.status-message,
.history-empty {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.section-heading p,
.wheel-topline p,
.status-message,
.history-empty {
  margin-bottom: 0;
}

.config-form,
.field-group {
  display: grid;
  gap: 12px;
}

.config-form {
  gap: 18px;
}

label {
  color: #293246;
  font-size: 14px;
  font-weight: 800;
}

input[type="text"],
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
  color: var(--text);
  background: #fbfcff;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input[type="text"] {
  height: 44px;
  padding: 0 13px;
}

textarea {
  min-height: 210px;
  resize: vertical;
  padding: 12px 13px;
  line-height: 1.55;
}

input[type="text"]:focus,
textarea:focus {
  border-color: rgba(47, 107, 255, 0.72);
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(47, 107, 255, 0.12);
}

input:disabled,
textarea:disabled {
  color: #7d8795;
  background: #eef2f7;
}

.field-hint {
  margin: -4px 0 0;
}

.error-message {
  min-height: 20px;
  margin: 0;
  color: #c1121f;
  font-size: 13px;
  font-weight: 700;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  color: var(--text);
}

.toggle-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.button,
.icon-text-button {
  min-height: 44px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: 0 16px;
  font-weight: 900;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

.button:not(:disabled):hover,
.icon-text-button:not(:disabled):hover {
  transform: translateY(-1px);
}

.button-primary {
  color: #ffffff;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  box-shadow: 0 14px 28px rgba(217, 31, 76, 0.22);
}

.button-primary:disabled {
  color: rgba(255, 255, 255, 0.76);
  background: #9aa4b2;
  box-shadow: none;
}

.button-secondary {
  color: var(--text);
  background: #ffffff;
  border-color: var(--line);
}

.button-secondary.is-stale {
  border-color: var(--amber);
  color: #9a5200;
  background: #fffaf0;
}

.wheel-panel {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 20px;
  min-width: 0;
}

.wheel-stage {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 600px;
  padding: 20px;
  overflow: hidden;
  background:
    linear-gradient(150deg, rgba(17, 24, 39, 0.96), rgba(37, 49, 76, 0.94)),
    var(--surface-strong);
}

.wheel-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #ffffff;
}

.wheel-topline p {
  color: rgba(255, 255, 255, 0.68);
}

.canvas-wrap {
  position: relative;
  display: grid;
  place-items: center;
  width: min(100%, 640px);
  aspect-ratio: 1;
  margin: 12px auto 0;
}

#wheelCanvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.16),
    0 28px 80px rgba(0, 0, 0, 0.28);
}

.wheel-pointer {
  position: absolute;
  z-index: 2;
  top: -2px;
  left: 50%;
  width: 0;
  height: 0;
  border-right: 18px solid transparent;
  border-left: 18px solid transparent;
  border-top: 36px solid var(--amber);
  filter: drop-shadow(0 5px 8px rgba(0, 0, 0, 0.28));
  transform: translateX(-50%);
}

.empty-state {
  position: absolute;
  display: grid;
  place-items: center;
  width: min(72%, 360px);
  min-height: 96px;
  padding: 18px;
  border: 1px dashed rgba(255, 255, 255, 0.32);
  border-radius: var(--radius);
  color: rgba(255, 255, 255, 0.78);
  background: rgba(255, 255, 255, 0.08);
  text-align: center;
  font-size: 15px;
  font-weight: 800;
}

.empty-state[hidden] {
  display: none;
}

.history-panel {
  min-height: 160px;
  padding: 18px;
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.icon-text-button {
  min-height: 34px;
  padding: 0 12px;
  color: var(--accent-strong);
  background: #fff1f4;
}

.history-list {
  display: grid;
  gap: 8px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.history-list li {
  display: flex;
  gap: 8px;
  align-items: baseline;
  padding: 10px 0;
  border-bottom: 1px solid rgba(216, 222, 234, 0.7);
}

.history-time {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.history-option {
  min-width: 0;
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.history-empty {
  margin: 14px 0 0;
}

.history-empty[hidden] {
  display: none;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(12, 18, 31, 0.58);
  backdrop-filter: blur(8px);
}

.modal-overlay[hidden] {
  display: none;
}

.result-modal {
  width: min(100%, 460px);
  border-radius: var(--radius);
  padding: 28px;
  background: #ffffff;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.24);
}

.result-modal h2 {
  margin-bottom: 22px;
  color: var(--text);
  font-size: 26px;
  line-height: 1.25;
  word-break: break-word;
}

@media (max-width: 768px) {
  .app-shell {
    width: min(100% - 24px, 620px);
    padding: 18px 0 24px;
  }

  .app-header {
    display: grid;
    align-items: start;
    margin-bottom: 16px;
  }

  h1 {
    font-size: 42px;
  }

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

  .config-panel,
  .wheel-stage,
  .history-panel {
    box-shadow: 0 16px 42px rgba(39, 53, 82, 0.1);
  }

  .config-panel,
  .wheel-stage,
  .history-panel {
    padding: 16px;
  }

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

  .wheel-stage {
    min-height: auto;
  }

  .canvas-wrap {
    margin-top: 18px;
  }

  .wheel-pointer {
    border-right-width: 14px;
    border-left-width: 14px;
    border-top-width: 30px;
  }
}

@media (max-width: 420px) {
  h1 {
    font-size: 34px;
  }

  .result-modal h2 {
    font-size: 22px;
  }

  .empty-state {
    width: 78%;
    min-height: 82px;
    font-size: 13px;
  }
}
