:root {
  color-scheme: light;
  --bg: #f6f7fb;
  --card: rgba(255, 255, 255, 0.92);
  --text: #172033;
  --muted: #667085;
  --border: #e4e7ec;
  --primary: #ec4899;
  --primary-2: #8b5cf6;
  --shadow: 0 18px 45px rgba(16, 24, 40, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 0%, rgba(236, 72, 153, 0.16), transparent 30%),
    radial-gradient(circle at 80% 20%, rgba(139, 92, 246, 0.18), transparent 28%),
    var(--bg);
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

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

.with-floating-topbar {
  padding-top: 112px;
}

.floating-topbar {
  position: fixed;
  top: 16px;
  left: 50%;
  z-index: 20;
  display: flex;
  width: min(1120px, calc(100% - 32px));
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px solid rgba(228, 231, 236, 0.82);
  border-radius: 999px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.84);
  box-shadow: 0 18px 45px rgba(16, 24, 40, 0.14);
  backdrop-filter: blur(16px);
  transform: translateX(-50%);
}

.topbar-button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0 16px;
  color: #475467;
  font-size: 14px;
  font-weight: 900;
  text-decoration: none;
  transition:
    transform 0.15s ease,
    background 0.15s ease,
    color 0.15s ease,
    border-color 0.15s ease;
}

.topbar-button:hover {
  border-color: rgba(139, 92, 246, 0.22);
  color: #7c3aed;
  background: rgba(139, 92, 246, 0.08);
  transform: translateY(-1px);
}

.topbar-button.active {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 10px 24px rgba(236, 72, 153, 0.24);
}

.hero-card,
.panel-card,
.task-card,
.toolbar,
.empty-state {
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.hero-card {
  display: flex;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
  padding: 28px;
}

.hero-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

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

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

h1 {
  margin-bottom: 8px;
  font-size: clamp(30px, 5vw, 48px);
  line-height: 1.05;
}

h2 {
  margin-bottom: 16px;
  font-size: 20px;
}

h3 {
  margin-bottom: 10px;
  font-size: 16px;
}

h4 {
  margin-bottom: 10px;
  font-size: 15px;
}

.subtitle,
.hint,
.message {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.7;
}

.admin-link,
.primary-button,
.ghost-button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0 18px;
  font-weight: 800;
  text-decoration: none;
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease,
    border-color 0.15s ease;
}

.admin-link,
.primary-button {
  border: 0;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 10px 24px rgba(236, 72, 153, 0.24);
}

.ghost-button {
  border: 1px solid var(--border);
  color: #475467;
  background: #fff;
}

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

.toolbar {
  display: flex;
  gap: 10px;
  margin: 18px 0;
  padding: 12px;
}

#searchInput,
#detailSearchInput,
.toolbar-select,
.form-row input,
.form-row select,
.form-row textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 16px;
  outline: none;
  color: var(--text);
  background: #fff;
}

#searchInput,
#detailSearchInput,
.toolbar-select,
.form-row input,
.form-row select,
.dynamic-row input {
  min-height: 44px;
  padding: 0 14px;
}

#searchInput:focus,
#detailSearchInput:focus,
.toolbar-select:focus,
.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus,
.dynamic-row input:focus {
  border-color: rgba(236, 72, 153, 0.55);
  box-shadow: 0 0 0 4px rgba(236, 72, 153, 0.12);
}

.task-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
  gap: 16px;
}

.task-card {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.detail-hall-card {
  grid-template-rows: auto minmax(0, 1fr);
  min-height: clamp(240px, 32vh, 420px);
  max-height: clamp(300px, 44vh, 520px);
  overflow: hidden;
}

.rule-task-card {
  grid-template-rows: auto minmax(0, 1fr);
  min-height: clamp(300px, 42vh, 520px);
  max-height: clamp(360px, 54vh, 640px);
  overflow: hidden;
}

.rule-card-header {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
}

.icon-action-row {
  display: inline-flex;
  flex: 0 0 auto;
  gap: 8px;
  align-items: center;
}

.toolbar-icon-button {
  flex: 0 0 auto;
}

.icon-button {
  display: inline-flex;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: #475467;
  background: #fff;
  box-shadow: 0 8px 18px rgba(16, 24, 40, 0.06);
  font-size: 18px;
  line-height: 1;
  transition:
    transform 0.15s ease,
    border-color 0.15s ease,
    background 0.15s ease,
    color 0.15s ease;
}

.icon-button:hover {
  border-color: rgba(236, 72, 153, 0.35);
  color: #9d174d;
  background: rgba(236, 72, 153, 0.08);
  transform: translateY(-1px);
}

.task-card h2 {
  margin: 0;
}

.task-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
}

.badge {
  border-radius: 999px;
  padding: 4px 9px;
  color: #7c3aed;
  background: rgba(139, 92, 246, 0.1);
}

.task-content {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: #344054;
  line-height: 1.75;
}

.rule-card-content {
  overflow: hidden;
  mask-image: linear-gradient(180deg, #000 72%, transparent 100%);
}

.modal-open {
  overflow: hidden;
}

.rule-detail-dialog[hidden] {
  display: none;
}

.rule-detail-dialog {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: clamp(16px, 4vw, 32px);
}

.rule-detail-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.38);
  backdrop-filter: blur(8px);
}

.rule-detail-panel {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(960px, 100%);
  max-height: min(82vh, 860px);
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--card);
  box-shadow: 0 28px 70px rgba(16, 24, 40, 0.22);
  overflow: hidden;
}

.rule-detail-header {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  padding: 18px;
}

.rule-detail-header h2 {
  margin: 0 0 10px;
}

.rule-detail-content,
.mission-detail-content {
  min-height: 0;
  margin: 0;
  overflow: auto;
  padding: 18px;
  word-break: break-word;
  color: #344054;
  background: #fff;
  line-height: 1.75;
}

.rule-detail-content {
  white-space: pre-wrap;
  font-family:
    "Cascadia Code",
    "Fira Code",
    Consolas,
    monospace;
}

.mission-detail-content {
  display: grid;
  gap: 16px;
}

.compact-detail-goal {
  min-height: 0;
}

.empty-state {
  padding: 40px 24px;
  text-align: center;
}

.panel-card {
  display: grid;
  gap: 16px;
  margin-top: 18px;
  padding: 22px;
}

.compact-panel {
  margin: 0;
  box-shadow: none;
}

.panel-title-row,
.button-row {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.compact-actions {
  justify-content: flex-start;
}

.form-row {
  display: grid;
  gap: 8px;
  color: #344054;
  font-weight: 800;
}

.form-row textarea {
  min-height: 360px;
  padding: 14px;
  resize: vertical;
  font-family:
    "Cascadia Code",
    "Fira Code",
    Consolas,
    monospace;
  line-height: 1.6;
}

.form-row .short-textarea,
.short-textarea {
  min-height: 112px;
}

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

.two-columns {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.full-span {
  grid-column: 1 / -1;
}

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

.category-pill {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(139, 92, 246, 0.22);
  border-radius: 999px;
  padding: 0 14px;
  color: #6941c6;
  background: rgba(139, 92, 246, 0.08);
  font-weight: 800;
}

.category-pill span {
  min-width: 22px;
  border-radius: 999px;
  padding: 2px 7px;
  color: #fff;
  background: rgba(139, 92, 246, 0.72);
  font-size: 12px;
}

.category-pill.active {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
}

.category-pill.active span {
  color: #7c3aed;
  background: #fff;
}

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

.dynamic-row input,
.dynamic-row textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 16px;
  outline: none;
  color: var(--text);
  background: #fff;
}

.dynamic-row textarea {
  padding: 14px;
  resize: vertical;
  line-height: 1.6;
}

.key-value-row {
  display: grid;
  grid-template-columns: minmax(150px, 0.7fr) minmax(220px, 1.4fr) auto;
  gap: 10px;
  align-items: center;
}

.extra-task-row,
.nested-card {
  display: grid;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
  background: rgba(249, 250, 251, 0.9);
}

.extra-task-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sticky-submit-panel {
  position: sticky;
  bottom: 16px;
  z-index: 2;
}

.json-preview {
  max-height: 460px;
  margin: 0;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
  white-space: pre-wrap;
  word-break: break-word;
  color: #344054;
  background: #0f172a;
  color: #e2e8f0;
  font-family:
    "Cascadia Code",
    "Fira Code",
    Consolas,
    monospace;
  line-height: 1.55;
}

.detail-task-list {
  display: grid;
  gap: 18px;
}

.detail-task-card {
  gap: 18px;
}

.detail-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 16px;
}

.detail-summary-grid p,
.detail-section p,
.nested-card p {
  margin-bottom: 0;
  line-height: 1.7;
}

.detail-section {
  display: grid;
  gap: 10px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.object-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.object-list div {
  display: grid;
  grid-template-columns: minmax(120px, 0.35fr) 1fr;
  gap: 10px;
  border-radius: 14px;
  padding: 10px 12px;
  background: #f9fafb;
}

.object-list dt {
  color: #7c3aed;
  font-weight: 900;
}

.object-list dd {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: #344054;
}

.extra-task-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.admin-bulk-panel {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  border: 1px solid rgba(139, 92, 246, 0.18);
  border-radius: 20px;
  padding: 16px;
  background: rgba(139, 92, 246, 0.06);
}

.admin-bulk-panel strong {
  display: block;
  margin-bottom: 4px;
  font-size: 18px;
}

.admin-bulk-actions {
  justify-content: flex-end;
}

.admin-select-control {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 10px;
  color: #475467;
  background: #fff;
  font-size: 12px;
  font-weight: 900;
}

.admin-select-control input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

.admin-task-card.selected {
  border-color: rgba(236, 72, 153, 0.5);
  box-shadow: 0 18px 45px rgba(236, 72, 153, 0.16);
}

.admin-login-card {
  max-width: 520px;
}

.admin-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.admin-stat-card,
.admin-section-card {
  border: 1px solid var(--border);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.78);
}

.admin-stat-card {
  display: grid;
  gap: 8px;
  padding: 16px;
}

.admin-stat-card span {
  color: var(--muted);
  font-weight: 800;
}

.admin-stat-card strong {
  color: #7c3aed;
  font-size: 34px;
  line-height: 1;
}

.admin-toolbar {
  margin: 0;
  box-shadow: none;
}

.admin-danger-row {
  justify-content: flex-start;
}

.danger-button,
.danger-icon {
  color: #b42318;
}

.danger-button:hover,
.danger-icon:hover {
  border-color: rgba(180, 35, 24, 0.28);
  color: #b42318;
  background: rgba(180, 35, 24, 0.08);
}

.admin-section-card {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.admin-task-card {
  grid-template-rows: auto minmax(0, 1fr);
  min-height: clamp(260px, 34vh, 460px);
  max-height: clamp(320px, 48vh, 560px);
  overflow: hidden;
}

.admin-dialog-pre {
  border-radius: 0;
}

.message-box {
  min-height: 48px;
  margin: 0;
  overflow: auto;
  border-radius: 16px;
  padding: 12px;
  white-space: pre-wrap;
  color: #344054;
  background: #f9fafb;
}

code {
  border-radius: 6px;
  padding: 2px 6px;
  color: #9d174d;
  background: rgba(236, 72, 153, 0.1);
}

@media (max-width: 760px) {
  .two-columns,
  .detail-summary-grid,
  .object-list div,
  .key-value-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .floating-topbar {
    overflow-x: auto;
    justify-content: flex-start;
    border-radius: 24px;
  }

  .topbar-button {
    flex: 0 0 auto;
  }
}

@media (max-width: 640px) {
  .hero-card,
  .toolbar,
  .button-row,
  .panel-title-row,
  .hero-actions,
  .rule-detail-header,
  .admin-bulk-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .with-floating-topbar {
    padding-top: 132px;
  }

  .rule-task-card,
  .detail-hall-card,
  .admin-task-card {
    min-height: 54vh;
    max-height: 62vh;
  }

  .rule-card-header {
    align-items: stretch;
    flex-direction: column;
  }

  .icon-action-row,
  .admin-bulk-actions {
    justify-content: flex-end;
  }

  .rule-detail-dialog {
    padding: 10px;
  }

  .rule-detail-panel {
    max-height: 88vh;
    border-radius: 20px;
  }
}
