:root {
  --bg: #f4f1ec;
  --ink: #1d1b16;
  --muted: #6b6257;
  --accent: #d66b2f;
  --accent-dark: #b6541f;
  --card: #ffffff;
  --line: #e3d9cc;
  --ok: #2c7a7b;
  --warn: #a63d40;
  --shadow: 0 8px 20px rgba(29, 27, 22, 0.12);
  --font-title: "Space Grotesk", "Trebuchet MS", sans-serif;
  --font-body: "IBM Plex Sans", "Segoe UI", sans-serif;
}

/* Themes */
body[data-theme="sand"], .theme-preview[data-theme="sand"] {
  --bg: #f4f1ec;
  --ink: #1d1b16;
  --muted: #6b6257;
  --accent: #d66b2f;
  --accent-dark: #b6541f;
  --card: #ffffff;
  --line: #e3d9cc;
}

body[data-theme="sage"], .theme-preview[data-theme="sage"] {
  --bg: #eef3ee;
  --ink: #1b231d;
  --muted: #5c6b60;
  --accent: #6f9b7a;
  --accent-dark: #4d7a59;
  --card: #ffffff;
  --line: #d6e0d8;
}

body[data-theme="slate"], .theme-preview[data-theme="slate"] {
  --bg: #eef1f4;
  --ink: #1a222c;
  --muted: #5a6673;
  --accent: #4f6fa6;
  --accent-dark: #3a5686;
  --card: #ffffff;
  --line: #d6dde6;
}

body[data-theme="sunset"], .theme-preview[data-theme="sunset"] {
  --bg: #f6efe8;
  --ink: #2b1f1a;
  --muted: #7a6a60;
  --accent: #d07a4a;
  --accent-dark: #b66136;
  --card: #ffffff;
  --line: #e7d7cb;
}

body[data-theme="ocean"], .theme-preview[data-theme="ocean"] {
  --bg: #eef6f7;
  --ink: #1c2a2d;
  --muted: #5b6b6f;
  --accent: #2f7e9b;
  --accent-dark: #23637a;
  --card: #ffffff;
  --line: #d6e4e8;
}

body[data-theme="forest"], .theme-preview[data-theme="forest"] {
  --bg: #eef4f0;
  --ink: #1f2a22;
  --muted: #5a6a5f;
  --accent: #3f7a5a;
  --accent-dark: #2e5f45;
  --card: #ffffff;
  --line: #d7e4dc;
}

body[data-theme="berry"], .theme-preview[data-theme="berry"] {
  --bg: #f4eef2;
  --ink: #2a1f28;
  --muted: #6a5a66;
  --accent: #8b4f7a;
  --accent-dark: #6e3c61;
  --card: #ffffff;
  --line: #e4d6df;
}

body[data-theme="clay"], .theme-preview[data-theme="clay"] {
  --bg: #f6f0ea;
  --ink: #2b211b;
  --muted: #6f5f55;
  --accent: #c67c5a;
  --accent-dark: #a86649;
  --card: #ffffff;
  --line: #e6d6cb;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background: radial-gradient(circle at top left, #fff5e9 0%, var(--bg) 55%, #efe6da 100%);
  min-height: 100vh;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 28px;
}

h1, h2, h3 {
  font-family: var(--font-title);
  margin: 0 0 8px;
}

h1 {
  font-size: 2rem;
}

h2 {
  font-size: 1.4rem;
}

p {
  margin: 0 0 12px;
  color: var(--muted);
}

section {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid.two {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

label {
  font-weight: 600;
  font-size: 0.9rem;
}

input, textarea, select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  font-family: var(--font-body);
  font-size: 0.95rem;
  background: #fff;
}

textarea {
  min-height: 90px;
  resize: vertical;
}

code {
  background: #f3eee6;
  padding: 2px 4px;
  border-radius: 6px;
  font-size: 0.9em;
}

a {
  color: var(--accent-dark);
}

button {
  border: none;
  background: var(--accent);
  color: white;
  padding: 10px 16px;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease;
}

button.secondary {
  background: #efe6da;
  color: var(--ink);
}

button.secondary.active {
  background: var(--accent);
  color: #fff;
}

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

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.toolbar-file {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 12px;
  cursor: pointer;
}

.toolbar-file input {
  display: none;
}

.theme-preview {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  background: #fff;
}

@media (max-width: 720px) {
  .event-card {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .event-card .inline {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .event-select {
    min-width: 100%;
  }

  .toolbar {
    flex-direction: column;
    align-items: flex-start;
  }
  .toolbar-actions {
    margin-left: 0;
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }
}

button.danger {
  background: var(--warn);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: #fbe7d8;
  color: var(--accent-dark);
  font-weight: 600;
  font-size: 0.8rem;
}

.event-focus {
  font-size: 1.6rem;
  margin: 6px 0 10px;
  color: var(--ink);
}

.event-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-radius: 16px;
  background: linear-gradient(135deg, #fff7ef, #ffffff);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.event-select {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 260px;
}

.dashboard-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(240px, 1fr));
  grid-auto-flow: row;
  margin-top: 16px;
}

.dashboard-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  background: #fff;
}

.task-row {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 12px;
  align-items: center;
}

.pie {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: conic-gradient(var(--accent) 0deg, var(--line) 0deg);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.75rem;
  color: var(--ink);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 600;
}

.status-pill.ok {
  color: var(--ok);
}

.status-pill.warn {
  color: var(--warn);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: currentColor;
}

.chat-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  max-height: 260px;
  overflow: auto;
  padding-right: 6px;
}

.chat-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
}

.chat-name {
  font-weight: 600;
}

.chat-meta {
  font-size: 0.75rem;
  color: var(--muted);
}

.chat-comment {
  margin-top: 4px;
  color: var(--ink);
}

.table-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  padding: 8px 10px;
  max-height: 260px;
  overflow: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table th,
.data-table td {
  padding: 8px 6px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.data-table thead {
  position: sticky;
  top: 0;
  background: #fff;
}

.card-list {
  display: grid;
  gap: 12px;
}

.card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  background: #fff;
}

.highlight {
  outline: 3px solid var(--accent);
  transition: outline 0.3s ease;
}

.task-card {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 12px;
  align-items: start;
}

.task-check {
  display: flex;
  align-items: center;
  justify-content: center;
}

.task-check input[type="checkbox"] {
  appearance: none;
  width: 36px;
  height: 36px;
  border: 3px solid var(--line);
  border-radius: 10px;
  background: #fff;
  position: relative;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.task-check input[type="checkbox"]::after {
  content: "";
  width: 18px;
  height: 10px;
  border-left: 4px solid #fff;
  border-bottom: 4px solid #fff;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -55%) rotate(-45deg) scale(0);
  transition: transform 0.15s ease;
}

.task-check input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(214, 107, 47, 0.15);
}

.task-check input[type="checkbox"]:checked::after {
  transform: translate(-50%, -55%) rotate(-45deg) scale(1);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(29, 27, 22, 0.4);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}

.modal.open {
  display: flex;
}

.modal-card {
  background: #fff;
  border-radius: 16px;
  padding: 20px;
  border: 1px solid var(--line);
  max-width: 520px;
  width: 100%;
  box-shadow: var(--shadow);
}

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 8px;
  background: #f3eee6;
  color: var(--muted);
  font-size: 0.78rem;
  margin-left: 6px;
}

.task-check input[type="checkbox"]:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.card header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}

.card-actions {
  display: flex;
  gap: 8px;
}

.notice {
  padding: 10px 12px;
  border-radius: 10px;
  background: #f8f0e5;
  color: var(--muted);
  font-size: 0.9rem;
}

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

.inline > * {
  flex: 1 1 140px;
}

.muted {
  color: var(--muted);
}

hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 16px 0;
}

@media (max-width: 720px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
    grid-auto-flow: row;
    grid-template-rows: none;
  }
  header {
    flex-direction: column;
    align-items: flex-start;
  }
}
