/* ==========================================================================
   Raid Availability — hourly matrix UI
   ========================================================================== */

:root {
  --bg: #070a12;
  --bg-soft: #0d1220;
  --bg-head: #101728;
  --panel: rgba(255, 255, 255, 0.045);
  --panel-hover: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);

  --text: #e9eefb;
  --text-dim: #94a2c0;
  --text-faint: #616f8d;

  --accent: #8b5cf6;
  --accent-2: #22d3ee;
  --green: #3ddc97;
  --green-deep: #0ea56e;
  --yellow: #fcd34d;
  --yellow-deep: #e79b06;
  --red: #fb7185;

  --h-hour: 26px;

  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 24px 60px -28px rgba(0, 0, 0, 0.95);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(900px 520px at 12% -10%, rgba(139, 92, 246, 0.22), transparent 60%),
    radial-gradient(760px 460px at 92% 0%, rgba(34, 211, 238, 0.14), transparent 62%),
    radial-gradient(700px 700px at 50% 120%, rgba(14, 165, 110, 0.1), transparent 65%);
  background-attachment: fixed;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

kbd {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 9px;
  line-height: 1;
  padding: 3px 4px;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-dim);
}

/* ---------------------------------------------------------------- layout */

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  padding: 14px 16px 0;
  gap: 10px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.logo {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  font-size: 20px;
  border-radius: 12px;
  background: linear-gradient(150deg, rgba(139, 92, 246, 0.35), rgba(34, 211, 238, 0.22));
  border: 1px solid var(--border-strong);
  box-shadow: 0 8px 22px -12px rgba(139, 92, 246, 0.9);
}

.brand-text h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.subtitle {
  margin: 1px 0 0;
  font-size: 12px;
  color: var(--text-faint);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* --------------------------------------------------------------- buttons */

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 13px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
  white-space: nowrap;
}

.btn:hover {
  background: var(--panel-hover);
  border-color: var(--border-strong);
}

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

.btn:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}

.btn.primary {
  color: #0a0716;
  background: linear-gradient(150deg, #a78bfa, #22d3ee);
  border-color: transparent;
  box-shadow: 0 10px 26px -14px rgba(139, 92, 246, 0.95);
}

.btn.primary:hover {
  filter: brightness(1.08);
}

.btn.icon {
  padding: 8px 11px;
  font-size: 14px;
  line-height: 1;
}

.btn.danger {
  color: #fff;
  background: linear-gradient(150deg, #f87171, #dc2626);
  border-color: transparent;
}

/* --------------------------------------------------------------- toolbar */

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
  backdrop-filter: blur(10px);
}

.paint {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.paint-label {
  margin-right: 2px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.chip {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 9px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.chip:hover {
  color: var(--text);
  background: var(--panel-hover);
}

.chip[aria-pressed="true"] {
  color: var(--text);
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--border-strong);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.14), 0 6px 18px -12px rgba(255, 255, 255, 0.7);
}

.chip:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}

.dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 50%;
}

.dot.g {
  background: var(--green);
  box-shadow: 0 0 8px rgba(61, 220, 151, 0.85);
}
.dot.y {
  background: var(--yellow);
  box-shadow: 0 0 8px rgba(252, 211, 77, 0.8);
}
.dot.n {
  background: transparent;
  border: 1.5px solid var(--text-faint);
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 999px;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  transition: color 0.2s ease, background 0.2s ease;
}

.pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.9;
}

.pill[data-state="saved"] {
  color: var(--green);
  background: rgba(61, 220, 151, 0.1);
  border-color: rgba(61, 220, 151, 0.3);
}

.pill[data-state="saving"] {
  color: var(--yellow);
  background: rgba(252, 211, 77, 0.1);
  border-color: rgba(252, 211, 77, 0.3);
}

.pill[data-state="error"] {
  color: var(--red);
  background: rgba(251, 113, 133, 0.12);
  border-color: rgba(251, 113, 133, 0.35);
}

.pill[data-state="loading"]::before {
  animation: pulse 1.1s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.25;
  }
  50% {
    opacity: 1;
  }
}

/* ------------------------------------------------------------------ grid */

.grid-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 200px;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(10, 15, 26, 0.9), rgba(7, 10, 18, 0.94));
  box-shadow: var(--shadow);
}

.grid-wrap::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

.grid-wrap::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  background-clip: content-box;
}

.grid-wrap::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
  background-clip: content-box;
}

.grid-wrap::-webkit-scrollbar-corner {
  background: transparent;
}

.grid {
  --w-name: 184px;
  --w-cell: 38px;
  display: grid;
  /* Columns stretch to fill the panel; below --w-cell width the panel scrolls. */
  grid-template-columns: var(--w-name) repeat(var(--n, 24), minmax(0, 1fr));
  width: 100%;
  min-width: calc(var(--w-name) + var(--n, 24) * var(--w-cell));
  font-variant-numeric: tabular-nums;
  user-select: none;
  -webkit-user-select: none;
}

.grid.painting {
  cursor: crosshair;
}

/* header cells */

.corner {
  position: sticky;
  left: 0;
  top: 0;
  z-index: 7;
  height: var(--h-hour);
  display: flex;
  align-items: center;
  padding-left: 12px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
  background: var(--bg-head);
  border-right: 1px solid var(--border-strong);
  border-bottom: 1px solid var(--border);
}

.hour {
  position: sticky;
  top: 0;
  z-index: 6;
  height: var(--h-hour);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-faint);
  background: var(--bg-head);
  border-bottom: 1px solid var(--border);
}

.hour.mark {
  color: var(--text-dim);
  border-left: 1px solid rgba(255, 255, 255, 0.1);
}

/* name column */

.name {
  position: sticky;
  left: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  height: 28px;
  padding: 0 8px 0 12px;
  font-size: 12.5px;
  font-weight: 600;
  background: var(--bg-soft);
  border-right: 1px solid var(--border-strong);
  border-bottom: 1px solid rgba(255, 255, 255, 0.045);
}

.name.mine {
  background: linear-gradient(90deg, rgba(139, 92, 246, 0.2), rgba(13, 18, 32, 0.98) 70%);
}

.name.mine::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(180deg, #a78bfa, #22d3ee);
}

.name-text {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.name .del {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  padding: 0;
  font-size: 12px;
  line-height: 1;
  color: var(--text-faint);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 5px;
  cursor: pointer;
  opacity: 0;
  transition: all 0.15s ease;
}

.name:hover .del,
.name .del:focus-visible {
  opacity: 1;
}

.name .del:hover {
  color: var(--red);
  border-color: rgba(251, 113, 133, 0.4);
  background: rgba(251, 113, 133, 0.12);
}

/* cells */

.cell {
  position: relative;
  height: 28px;
  padding: 2px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.035);
  cursor: cell;
}

.cell::after {
  content: "";
  position: absolute;
  inset: 2px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.045);
  transition: background 0.12s ease, transform 0.1s ease, box-shadow 0.12s ease;
}

.cell.mark {
  box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.07);
}

/* Your own row: tinted across every cell, not just the name column. */
.cell.mine {
  background: rgba(139, 92, 246, 0.085);
}

.cell.mine::after {
  background: rgba(167, 139, 250, 0.13);
}

.cell:hover::after {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.06);
}

.cell:focus-visible {
  outline: none;
}

.cell:focus-visible::after {
  outline: 2px solid var(--accent-2);
  outline-offset: 1px;
}

.cell[data-s="1"]::after {
  background: linear-gradient(180deg, var(--green), var(--green-deep));
  box-shadow: 0 0 0 1px rgba(61, 220, 151, 0.45), 0 3px 10px -4px rgba(14, 165, 110, 0.95);
}

.cell[data-s="2"]::after {
  background: linear-gradient(180deg, var(--yellow), var(--yellow-deep));
  box-shadow: 0 0 0 1px rgba(252, 211, 77, 0.4), 0 3px 10px -4px rgba(231, 155, 6, 0.9);
}

.cell.flash::after {
  animation: flash 0.9s ease-out 2;
}

@keyframes flash {
  0%,
  100% {
    box-shadow: 0 0 0 1px transparent;
  }
  50% {
    box-shadow: 0 0 0 2px var(--accent-2), 0 0 14px rgba(34, 211, 238, 0.8);
  }
}

/* availability footer */

.foot-label {
  position: sticky;
  left: 0;
  bottom: 0;
  z-index: 7;
  display: flex;
  align-items: center;
  height: 30px;
  padding-left: 12px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-faint);
  background: #0a1020;
  border-top: 2px solid var(--border-strong);
  border-right: 1px solid var(--border-strong);
}

.count {
  position: sticky;
  bottom: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  height: 30px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-faint);
  background: #0a1020;
  border-top: 2px solid var(--border-strong);
  border-left: 1px solid rgba(255, 255, 255, 0.04);
}

.count.mid {
  color: var(--text-dim);
}

.count.hot {
  color: #04140d;
  font-weight: 800;
  background: linear-gradient(180deg, var(--green), var(--green-deep));
}

/* ----------------------------------------------------------- empty state */

.empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  pointer-events: none;
}

.empty > div {
  pointer-events: auto;
  max-width: 340px;
  padding: 26px 28px;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(13, 18, 32, 0.94);
  box-shadow: var(--shadow);
}

.empty-icon {
  font-size: 30px;
  margin-bottom: 6px;
}

.empty h2 {
  margin: 0 0 4px;
  font-size: 15px;
}

.empty p {
  margin: 0 0 16px;
  font-size: 12.5px;
  color: var(--text-dim);
}

/* ---------------------------------------------------------------- footer */

.footer-hint {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 6px 4px 10px;
  font-size: 11px;
  color: var(--text-faint);
}

.time-note {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-faint);
}

/* ----------------------------------------------------------------- modal */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(4, 7, 14, 0.72);
  backdrop-filter: blur(6px);
  animation: fade 0.14s ease-out;
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

.modal {
  width: min(430px, 100%);
  padding: 22px 24px 20px;
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  background: linear-gradient(180deg, #131a2b, #0b101c);
  box-shadow: 0 40px 90px -30px rgba(0, 0, 0, 1);
  animation: pop 0.16s cubic-bezier(0.2, 1.3, 0.5, 1);
}

@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.97);
  }
}

.modal h2 {
  margin: 0 0 8px;
  font-size: 16px;
  letter-spacing: -0.01em;
}

.modal-body {
  font-size: 13px;
  color: var(--text-dim);
}

.modal input[type="text"] {
  width: 100%;
  margin-top: 12px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--text);
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
}

.modal input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.25);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

/* ---------------------------------------------------------------- toasts */

.toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(360px, calc(100vw - 32px));
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 10px 13px;
  font-size: 12.5px;
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  background: rgba(16, 23, 40, 0.97);
  box-shadow: var(--shadow);
  animation: slide-in 0.18s ease-out;
}

.toast::before {
  content: "";
  flex: 0 0 auto;
  width: 3px;
  align-self: stretch;
  border-radius: 2px;
  background: var(--accent-2);
}

.toast.warn::before {
  background: var(--yellow);
}

.toast.error::before {
  background: var(--red);
}

.toast.ok::before {
  background: var(--green);
}

.toast.leaving {
  opacity: 0;
  transform: translateX(12px);
  transition: all 0.2s ease;
}

@keyframes slide-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* ------------------------------------------------------------ responsive */

@media (max-width: 720px) {
  .app {
    padding: 10px 10px 0;
    gap: 8px;
  }

  .brand-text h1 {
    font-size: 15px;
  }

  .subtitle {
    display: none;
  }

  .logo {
    width: 34px;
    height: 34px;
    font-size: 17px;
  }

  .btn {
    padding: 7px 10px;
    font-size: 12px;
  }

  .grid {
    --w-name: 132px;
    --w-cell: 34px;
  }

  .footer-hint {
    font-size: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
