:root {
  --bg: #f3efe6;
  --bg-accent: #e2d2bd;
  --panel: rgba(255, 251, 245, 0.82);
  --panel-strong: #fffaf1;
  --text: #1f1c18;
  --muted: #665e55;
  --line: rgba(31, 28, 24, 0.12);
  --line-strong: rgba(31, 28, 24, 0.24);
  --primary: #c44c2d;
  --primary-dark: #98361d;
  --shadow: 0 20px 60px rgba(90, 58, 24, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Avenir Next", "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(196, 76, 45, 0.22), transparent 24rem),
    radial-gradient(circle at 85% 18%, rgba(226, 210, 189, 0.95), transparent 18rem),
    linear-gradient(135deg, var(--bg) 0%, #efe3d2 48%, #efe8dd 100%);
}

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

.hero {
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--primary-dark);
  font-size: 0.82rem;
  font-weight: 700;
}

h1,
h2,
h3 {
  margin: 0;
}

h1 {
  font-size: clamp(2.6rem, 5vw, 4.8rem);
  line-height: 0.95;
}

.intro {
  max-width: 780px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.6;
}

.panel {
  backdrop-filter: blur(12px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 20px;
}

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

.panel-header p {
  margin: 8px 0 0;
  color: var(--muted);
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.button {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  font: inherit;
  font-weight: 700;
  color: #fffaf4;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
  box-shadow: 0 10px 24px rgba(152, 54, 29, 0.2);
}

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

.button:active {
  transform: translateY(1px);
}

.button-secondary {
  color: var(--text);
  background: var(--panel-strong);
  border: 1px solid var(--line);
  box-shadow: none;
}

.field {
  display: block;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.92rem;
  font-weight: 700;
}

textarea,
input,
select {
  width: 100%;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
  color: var(--text);
  font: inherit;
  padding: 14px 16px;
}

textarea {
  min-height: 320px;
  resize: vertical;
  font-family: "SFMono-Regular", "Menlo", "Consolas", "Liberation Mono", monospace;
  line-height: 1.6;
}

input,
select {
  min-height: 52px;
}

textarea:focus,
input:focus,
select:focus {
  outline: 2px solid rgba(196, 76, 45, 0.18);
  border-color: var(--line-strong);
}

.options-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 16px 0;
}

.status {
  min-height: 28px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.95rem;
}

.magnetic-card {
  margin-top: 16px;
  padding: 18px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(196, 76, 45, 0.06), rgba(255, 250, 241, 0.88));
}

.magnetic-header {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
}

.magnetic-header p {
  margin: 8px 0 0;
  color: var(--muted);
}

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

.editor-empty {
  padding: 18px;
  border: 1px dashed var(--line-strong);
  border-radius: 18px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.38);
}

.magnetic-editor[hidden] {
  display: none;
}

.editor-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 252, 247, 0.82);
}

.moment-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.moment-table th,
.moment-table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.moment-table thead th {
  font-size: 0.86rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  background: rgba(196, 76, 45, 0.05);
}

.moment-table tbody tr:last-child td {
  border-bottom: 0;
}

.moment-table code {
  font-family: "SFMono-Regular", "Menlo", "Consolas", "Liberation Mono", monospace;
  font-size: 0.9rem;
}

.moment-input {
  min-height: 42px;
  padding: 10px 12px;
  border-radius: 12px;
}

.moment-col-collinear {
  display: none;
}

.collinear-mode .moment-col-vector {
  display: none;
}

.collinear-mode .moment-col-collinear {
  display: table-cell;
}

.toggle {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  font-weight: 700;
}

.toggle input {
  width: 18px;
  height: 18px;
  min-height: auto;
  margin: 0;
}

.status.error {
  color: #9f1d1d;
}

.status.success {
  color: #1d6b43;
}

.notes {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 250, 241, 0.85);
  border: 1px solid var(--line);
  color: var(--muted);
}

.notes p {
  margin: 0;
}

.notes p + p {
  margin-top: 8px;
}

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

@media (max-width: 680px) {
  .app-shell {
    width: min(100% - 20px, 100%);
    padding: 28px 0 36px;
  }

  .panel {
    padding: 18px;
    border-radius: 20px;
  }

  .panel-header {
    flex-direction: column;
  }

  .actions {
    width: 100%;
  }

  .button {
    flex: 1 1 180px;
  }

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

  .magnetic-header {
    flex-direction: column;
  }

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

  .editor-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  textarea {
    min-height: 260px;
  }
}
