:root {
  --bg: #f5f7f8;
  --panel: #ffffff;
  --panel-soft: #f9fbfa;
  --text: #17201d;
  --muted: #6d7773;
  --line: #e5eae7;
  --green: #06c755;
  --green-dark: #05a948;
  --green-soft: #e9fbf0;
  --danger: #d84343;
  --shadow: 0 16px 40px rgba(20, 41, 31, 0.08);
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 12px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans Thai", sans-serif;
  color: var(--text);
  background: var(--bg);
}

button,
input { font: inherit; }

button { cursor: pointer; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  background: #111a17;
  color: white;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 28px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--green);
  color: white;
  font-weight: 900;
  font-size: 22px;
  box-shadow: 0 10px 25px rgba(6, 199, 85, 0.25);
}

.brand strong,
.brand span { display: block; }
.brand span { color: #9eaaa5; font-size: 12px; margin-top: 2px; }

.nav-list { display: grid; gap: 8px; }

.nav-item {
  width: 100%;
  border: 0;
  border-radius: 14px;
  padding: 13px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  color: #b8c2be;
  text-align: left;
  transition: 160ms ease;
}

.nav-item:hover { background: rgba(255,255,255,0.06); color: white; }
.nav-item.active { background: rgba(6,199,85,0.16); color: #e9fff1; }
.nav-item span { width: 24px; text-align: center; font-size: 18px; }

.sidebar-footer { margin-top: auto; }

.profile-card {
  width: 100%;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px;
  padding: 10px;
  display: flex;
  gap: 10px;
  align-items: center;
  background: rgba(255,255,255,0.04);
  color: white;
  text-align: left;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--green);
  font-weight: 800;
}

.profile-card strong,
.profile-card small { display: block; }
.profile-card small { color: #91a099; margin-top: 2px; }

.main-content { padding: 34px clamp(24px, 4vw, 56px) 60px; min-width: 0; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 30px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green-dark);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: 12px;
  font-weight: 800;
}

h1,h2,h3,p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(26px, 3vw, 38px); line-height: 1.15; }
h2 { font-size: 24px; margin-bottom: 8px; }
h3 { font-size: 18px; margin-bottom: 8px; }
p { color: var(--muted); line-height: 1.65; }

.primary-button,
.secondary-button,
.text-button,
.danger-text-button {
  border: 0;
  border-radius: 13px;
  padding: 11px 16px;
  font-weight: 750;
  transition: 160ms ease;
}

.primary-button { background: var(--green); color: white; box-shadow: 0 10px 24px rgba(6,199,85,.2); }
.primary-button:hover { background: var(--green-dark); transform: translateY(-1px); }
.secondary-button { background: #eef2f0; color: var(--text); }
.secondary-button:hover { background: #e4eae7; }
.text-button { background: transparent; color: var(--green-dark); padding-inline: 0; }
.danger-text-button { background: transparent; color: var(--danger); }

.view { display: none; }
.view.active { display: block; animation: fade-in 180ms ease; }
@keyframes fade-in { from { opacity: .4; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.welcome-card {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(260px, .65fr);
  min-height: 300px;
  overflow: hidden;
  border-radius: 28px;
  background: linear-gradient(135deg, #ffffff 0%, #f2fff7 100%);
  border: 1px solid #e3f5e9;
  box-shadow: var(--shadow);
}

.welcome-card > div:first-child { padding: clamp(30px, 5vw, 54px); }
.welcome-card h2 { max-width: 650px; font-size: clamp(30px, 4vw, 48px); line-height: 1.08; }
.welcome-card p { max-width: 650px; font-size: 16px; }

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 7px 11px;
  background: var(--green-soft);
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 14px;
}
.pill.soft { background: #eefbf3; }

.welcome-visual { position: relative; min-height: 260px; background: radial-gradient(circle at 50% 50%, rgba(6,199,85,.16), transparent 68%); }
.sticker-bubble {
  position: absolute;
  display: grid;
  place-items: center;
  background: white;
  box-shadow: 0 20px 44px rgba(25,56,40,.16);
  border: 1px solid #e9eeeb;
}
.bubble-one { width: 130px; height: 130px; border-radius: 36px; font-size: 58px; left: 8%; top: 18%; transform: rotate(-9deg); }
.bubble-two { width: 96px; height: 96px; border-radius: 30px; font-size: 42px; right: 14%; top: 16%; transform: rotate(11deg); }
.bubble-three { width: 112px; height: 112px; border-radius: 34px; font-size: 48px; right: 22%; bottom: 11%; transform: rotate(-3deg); }

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

.stat-card,
.project-card,
.workspace-card,
.helper-card {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 8px 28px rgba(25,44,34,.04);
}

.stat-card { border-radius: var(--radius-md); padding: 20px; }
.stat-card span,
.stat-card strong,
.stat-card small { display: block; }
.stat-card span { color: var(--muted); font-size: 13px; }
.stat-card strong { font-size: 30px; margin: 8px 0 3px; }
.stat-card small { color: #929b97; }

.section-heading {
  margin: 24px 0 14px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}
.section-heading.compact { margin-top: 28px; }
.section-heading h2 { margin-bottom: 0; }

.project-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 16px;
}

.project-card {
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: 160ms ease;
}
.project-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }

.project-cover {
  aspect-ratio: 16 / 9;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #f1f4f2, #e7f8ed);
  font-size: 54px;
  position: relative;
}

.project-count {
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 6px 9px;
  border-radius: 999px;
  background: rgba(17,26,23,.76);
  color: white;
  font-size: 11px;
  backdrop-filter: blur(8px);
}

.project-body { padding: 16px; }
.project-body h3 { margin-bottom: 6px; }
.project-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 12px; }
.status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 8px;
  font-size: 11px;
  font-weight: 800;
}
.status.draft { background: #f0f1f2; color: #606a66; }
.status.ready { background: #e9fbf0; color: #04863a; }
.status.selling { background: #edf5ff; color: #2763a7; }
.status.attention { background: #fff3df; color: #a66200; }

.stepper {
  margin-bottom: 20px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.step {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 12px 14px;
  border-radius: 14px;
  color: #8a9490;
  background: #eef1ef;
}
.step span {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #dce2df;
  font-weight: 800;
}
.step.active { color: #07562c; background: var(--green-soft); }
.step.active span { color: white; background: var(--green); }

.create-layout { display: grid; grid-template-columns: minmax(0,1fr) 300px; gap: 18px; align-items: start; }
.workspace-card { border-radius: var(--radius-lg); padding: 24px; }
.helper-card { border-radius: var(--radius-md); padding: 22px; position: sticky; top: 24px; }

.workspace-heading { display: flex; align-items: start; justify-content: space-between; gap: 20px; }
.image-counter { flex: 0 0 auto; padding: 8px 11px; border-radius: 999px; background: #f1f4f2; color: var(--muted); font-size: 12px; font-weight: 750; }

.dropzone {
  width: 100%;
  min-height: 250px;
  border: 2px dashed #bdd9c8;
  border-radius: 22px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 7px;
  padding: 28px;
  color: var(--text);
  background: #fbfefc;
  transition: 160ms ease;
}
.dropzone:hover,
.dropzone.dragover { border-color: var(--green); background: #f2fff7; }
.dropzone span,
.dropzone small { color: var(--muted); }
.dropzone small { margin-top: 8px; max-width: 560px; line-height: 1.5; }
.drop-icon {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: var(--green-soft);
  color: var(--green-dark) !important;
  font-size: 30px;
  font-weight: 800;
}

.upload-toolbar { margin-top: 18px; display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.upload-toolbar strong,
.upload-toolbar span { display: block; }
.upload-toolbar span { color: var(--muted); font-size: 12px; margin-top: 3px; }
.toolbar-actions { display: flex; gap: 8px; }
.hidden { display: none !important; }

.sticker-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0,1fr));
  gap: 10px;
}

.sticker-card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px;
  background: #fff;
  cursor: grab;
}
.sticker-card.dragging { opacity: .45; }
.sticker-card img { width: 100%; aspect-ratio: 1; object-fit: contain; display: block; border-radius: 10px; background: #f7f9f8; }
.sticker-index { margin-top: 7px; color: var(--muted); font-size: 11px; text-align: center; font-weight: 800; }
.remove-sticker {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 27px;
  height: 27px;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(17,26,23,.76);
  color: white;
  opacity: 0;
  transition: 140ms ease;
}
.sticker-card:hover .remove-sticker { opacity: 1; }

.check-list { list-style: none; padding: 0; margin: 18px 0 0; display: grid; gap: 10px; color: #41504a; }

.library-toolbar { display: flex; justify-content: space-between; gap: 14px; align-items: center; }
.search-box {
  min-width: min(100%, 360px);
  display: flex;
  align-items: center;
  gap: 8px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0 13px;
}
.search-box input { width: 100%; border: 0; outline: 0; background: transparent; padding: 12px 0; color: var(--text); }
.filter-group { display: flex; gap: 7px; flex-wrap: wrap; }
.filter-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 11px;
  background: white;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}
.filter-chip.active { border-color: #b6eccb; background: var(--green-soft); color: var(--green-dark); }
.result-count { color: var(--muted); font-size: 13px; }

.empty-state {
  grid-column: 1 / -1;
  padding: 42px 20px;
  border: 1px dashed #ccd5d1;
  border-radius: 18px;
  text-align: center;
  color: var(--muted);
  background: rgba(255,255,255,.5);
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  max-width: 360px;
  padding: 12px 15px;
  border-radius: 13px;
  background: #13211b;
  color: white;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: 180ms ease;
}
.toast.show { opacity: 1; transform: none; }

@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .project-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .create-layout { grid-template-columns: 1fr; }
  .helper-card { position: static; }
  .sticker-grid { grid-template-columns: repeat(4, minmax(0,1fr)); }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar {
    position: sticky;
    z-index: 10;
    top: 0;
    width: 100%;
    height: auto;
    padding: 10px 14px;
    flex-direction: row;
    align-items: center;
    gap: 10px;
  }
  .brand { padding: 0; margin-right: auto; }
  .brand span,
  .sidebar-footer { display: none; }
  .brand-mark { width: 36px; height: 36px; border-radius: 11px; font-size: 18px; }
  .nav-list { display: flex; gap: 4px; }
  .nav-item { width: auto; padding: 9px; }
  .nav-item span { width: auto; }
  .nav-item { font-size: 0; }
  .nav-item span { font-size: 19px; }
  .main-content { padding: 24px 16px 50px; }
  .topbar { align-items: flex-start; }
  .topbar .primary-button { display: none; }
  .welcome-card { grid-template-columns: 1fr; }
  .welcome-visual { display: none; }
  .welcome-card > div:first-child { padding: 28px 22px; }
  .project-grid { grid-template-columns: 1fr; }
  .stepper { grid-template-columns: repeat(4, minmax(0,1fr)); gap: 5px; }
  .step { justify-content: center; padding: 8px; }
  .step strong { display: none; }
  .workspace-card { padding: 18px; }
  .workspace-heading { display: block; }
  .image-counter { display: inline-block; margin-bottom: 10px; }
  .sticker-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .upload-toolbar,
  .library-toolbar { align-items: stretch; flex-direction: column; }
  .search-box { min-width: 0; width: 100%; }
  .toolbar-actions { flex-wrap: wrap; }
}

@media (max-width: 430px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .stat-card { padding: 16px; }
  .sticker-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
