@import url("https://fonts.googleapis.com/css2?family=Chakra+Petch:wght@400;500;600;700&family=Rajdhani:wght@500;700&display=swap");

:root {
  --bg: #090b0e;
  --panel: #11161c;
  --panel-2: #171f27;
  --line: #2a3642;
  --text: #e8f2f3;
  --muted: #9fb4b6;
  --accent: #3effa2;
  --danger: #f44336;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
}

body {
  font-family: "Chakra Petch", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 80% 10%, rgba(62, 255, 162, 0.12), transparent 28%),
    radial-gradient(circle at 10% 80%, rgba(244, 67, 54, 0.1), transparent 26%),
    linear-gradient(135deg, #06080c, #0b1016 55%, #121b22);
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--accent) #0d1218;
}

*::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

*::-webkit-scrollbar-track {
  background: linear-gradient(180deg, #0b1016, #10171f);
  border: 1px solid var(--line);
}

*::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #2ed38a, #1ca965);
  border: 2px solid #0d1218;
  border-radius: 10px;
}

*::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #52ffb0, #23c877);
}

*::-webkit-scrollbar-corner {
  background: #0d1218;
}

h1,
h2,
h3,
strong {
  margin: 0;
  font-family: "Rajdhani", sans-serif;
  letter-spacing: 0.04em;
}

button,
input,
select {
  font-family: inherit;
}

button {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #1a242e, #131a21);
  color: var(--text);
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease;
}

button:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

input {
  border: 1px solid var(--line);
  background: #0d1218;
  color: var(--text);
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
}

label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.86rem;
  color: var(--muted);
}

.panel-help {
  margin: 0;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0e141a;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.35;
}

.hidden {
  display: none !important;
}

.app-shell {
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(62, 255, 162, 0.2);
  background:
    linear-gradient(110deg, rgba(62, 255, 162, 0.09), transparent 22%),
    linear-gradient(290deg, rgba(255, 62, 62, 0.08), transparent 22%),
    rgba(8, 12, 16, 0.92);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background:
    linear-gradient(135deg, #3effa2, #14a3ff 55%, #ff4f4f);
  box-shadow:
    0 0 0 1px rgba(62, 255, 162, 0.25),
    0 8px 24px rgba(62, 255, 162, 0.2);
}

.brand-copy {
  min-width: 0;
}

.brand-copy h1 {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1;
}

.brand-copy p {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.74rem;
  letter-spacing: 0.06em;
}

.brand-chip {
  border: 1px solid rgba(62, 255, 162, 0.45);
  color: #cbffe8;
  background: rgba(62, 255, 162, 0.12);
  border-radius: 999px;
  padding: 0.2rem 0.45rem;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: flex-end;
}

.topbar-actions button {
  border-color: rgba(255, 255, 255, 0.2);
  background: linear-gradient(180deg, #18232d, #111922);
}

.topbar-actions button:hover {
  border-color: rgba(62, 255, 162, 0.7);
  box-shadow: 0 0 0 1px rgba(62, 255, 162, 0.2);
}

.dashboard {
  padding: 1rem;
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(0, 1fr);
  align-content: start;
}

.dashboard-hero {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 1rem;
  border: 1px solid rgba(62, 255, 162, 0.3);
  background:
    radial-gradient(circle at 8% 25%, rgba(62, 255, 162, 0.16), transparent 38%),
    radial-gradient(circle at 82% 78%, rgba(255, 62, 62, 0.12), transparent 34%),
    linear-gradient(160deg, rgba(19, 27, 35, 0.98), rgba(10, 16, 23, 0.96));
}

.dashboard-hero-main {
  display: grid;
  gap: 0.45rem;
  align-content: center;
}

.hero-kicker {
  margin: 0;
  color: var(--accent);
  letter-spacing: 0.15em;
  font-size: 0.75rem;
  font-weight: 700;
}

.dashboard-hero h2 {
  font-size: clamp(1.35rem, 2.6vw, 2rem);
}

.hero-sub {
  margin: 0;
  color: var(--muted);
  max-width: 62ch;
  line-height: 1.45;
}

.dashboard-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.6rem;
}

.stat-box {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 0.7rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.01));
  display: grid;
  gap: 0.15rem;
  align-content: center;
}

.stat-value {
  font-family: "Rajdhani", sans-serif;
  font-size: 1.55rem;
  font-weight: 700;
  color: #f5fffa;
}

.stat-label {
  color: var(--muted);
  font-size: 0.76rem;
}

.card {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(19, 27, 35, 0.9), rgba(13, 18, 24, 0.88));
  border-radius: 12px;
  padding: 1rem;
  display: grid;
  gap: 0.8rem;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
}

.card-sub {
  margin: -0.25rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.row input {
  flex: 1;
}

.project-list {
  display: grid;
  gap: 0.65rem;
}

.project-item {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background:
    linear-gradient(180deg, rgba(16, 23, 31, 0.95), rgba(12, 18, 24, 0.94));
  border-radius: 12px;
  padding: 0.75rem;
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  align-items: flex-start;
  transition: border-color 0.12s ease, transform 0.12s ease;
}

.project-item:hover {
  border-color: rgba(62, 255, 162, 0.5);
  transform: translateY(-1px);
}

.project-info {
  min-width: 0;
  display: grid;
  gap: 0.2rem;
}

.project-title {
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-meta {
  color: #b6cacc;
  font-size: 0.77rem;
}

.project-badge {
  width: fit-content;
  border: 1px solid rgba(62, 255, 162, 0.45);
  background: rgba(62, 255, 162, 0.1);
  color: #cbffe8;
  border-radius: 999px;
  padding: 0.12rem 0.45rem;
  font-size: 0.68rem;
  letter-spacing: 0.05em;
}

.project-item small {
  color: var(--muted);
  display: block;
}

.project-time {
  color: #89a2a5;
  font-size: 0.74rem;
}

.project-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 42%;
}

.project-actions button {
  font-size: 0.75rem;
  padding: 0.35rem 0.55rem;
}

.dashboard-create-card {
  position: relative;
  overflow: hidden;
}

.dashboard-create-card::after {
  content: "";
  position: absolute;
  inset: -40% auto auto -10%;
  width: 45%;
  aspect-ratio: 1 / 1;
  background: radial-gradient(circle, rgba(62, 255, 162, 0.18), transparent 65%);
  pointer-events: none;
}

.dashboard-projects-card {
  min-height: 280px;
}

.empty-state {
  margin: 0;
  padding: 0.7rem 0.8rem;
  border: 1px dashed rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.02);
}

.editor-layout {
  min-height: 0;
  display: grid;
  grid-template-columns: 260px 1fr 320px;
  grid-template-rows: 1fr auto;
}

.panel {
  border-right: 1px solid var(--line);
  background: rgba(13, 18, 24, 0.92);
  overflow: auto;
  padding: 0.85rem;
  display: grid;
  gap: 0.75rem;
  align-content: start;
}

.panel.right {
  border-right: none;
  border-left: 1px solid var(--line);
}

.tool-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
  padding: 0.55rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.01));
}

.tool {
  text-align: left;
  font-weight: 600;
}

.tool.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(62, 255, 162, 0.25);
  background: linear-gradient(180deg, rgba(62, 255, 162, 0.2), rgba(22, 35, 30, 0.65));
}

.tool-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
}

.tool-actions button {
  font-size: 0.82rem;
  min-height: 34px;
}

.tool-selection-info {
  color: var(--muted);
  font-size: 0.78rem;
  border: 1px dashed rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  padding: 0.4rem 0.5rem;
  background: rgba(255, 255, 255, 0.02);
}

.canvas-wrap {
  min-width: 0;
  min-height: 0;
  background:
    linear-gradient(45deg, rgba(62, 255, 162, 0.03), transparent 40%),
    linear-gradient(160deg, rgba(244, 67, 54, 0.04), transparent 40%),
    #0b1016;
}

.canvas-scroll {
  width: 100%;
  height: 100%;
  overflow: auto;
  padding: 1rem;
  touch-action: none;
}

canvas {
  display: block;
  border: 1px solid var(--line);
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: crosshair;
  touch-action: none;
}

.palette-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.35rem;
}

.standard-palette-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.swatch {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  cursor: pointer;
  background: transparent;
  padding: 0;
}

.swatch:disabled {
  cursor: default;
}

.swatch:hover,
.swatch.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(62, 255, 162, 0.35);
  transform: translateY(-1px);
}

.layer-list {
  display: grid;
  gap: 0.45rem;
}

.layer-item {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.35rem;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.45rem;
}

.layer-item.active {
  border-color: var(--accent);
}

.layer-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

.layer-select {
  flex: 1;
  text-align: left;
}

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

.layer-edit-row {
  display: grid;
  grid-template-columns: 1fr 92px;
  gap: 0.4rem;
  align-items: center;
}

.layer-name-input {
  width: 100%;
}

.layer-opacity {
  width: 100%;
}

.layer-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.25rem;
}

.layer-actions button {
  font-size: 0.75rem;
  padding: 0.32rem 0.42rem;
  text-align: left;
  min-height: 32px;
  line-height: 1.15;
}

.bottombar {
  grid-column: 1 / -1;
  border-top: 1px solid var(--line);
  background: rgba(9, 12, 16, 0.95);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  align-items: center;
}

.status {
  margin: 0;
  color: var(--muted);
  text-align: right;
}

.login-shell {
  width: 100%;
  height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.login-card {
  width: min(100%, 430px);
  display: grid;
  gap: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, #11161d, #0e141a);
  padding: 1.3rem;
}

.login-card p {
  margin: 0;
  color: var(--muted);
}

.error {
  margin: 0;
  color: #ff8e8e;
}

@media (max-width: 1200px) {
  .editor-layout {
    grid-template-columns: 220px 1fr;
  }

  .tool-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .panel.right {
    grid-column: 1 / -1;
    border-left: none;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 900px) {
  .dashboard-hero {
    grid-template-columns: 1fr;
  }

  .dashboard-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
    gap: 0.7rem;
  }

  .topbar-brand {
    width: 100%;
  }

  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .editor-layout {
    grid-template-columns: 1fr;
  }

  .panel.left {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .panel.left,
  .panel.right {
    max-height: 35vh;
  }

  .canvas-wrap {
    min-height: 52vh;
  }

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

  .status {
    text-align: left;
  }
}

@media (hover: none) and (pointer: coarse) {
  button,
  input,
  select {
    min-height: 44px;
  }

  .tool-actions button,
  .project-actions button,
  .layer-actions button {
    min-height: 42px;
    font-size: 0.85rem;
  }

  .tool-list {
    gap: 0.55rem;
  }

  .swatch {
    border-width: 2px;
  }

  .canvas-scroll {
    padding: 0.7rem;
  }
}

@media (max-width: 620px) {
  .dashboard-stats {
    grid-template-columns: 1fr;
  }

  .project-item {
    flex-direction: column;
  }

  .project-actions {
    max-width: 100%;
    width: 100%;
    justify-content: flex-start;
  }
}
