:root {
  --bg: #0f1117;
  --bg2: #161b26;
  --bg3: #1c2333;
  --border: #2a3348;
  --text: #e8ecf4;
  --muted: #8b95a8;
  --accent: #6c9eff;
  --accent2: #8b7cf6;
  --ok: #3dd68c;
  --danger: #ff6b7a;
  --warn: #f0b429;
  --radius: 12px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  --font: "Pretendard", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "Cascadia Code", "Consolas", "SF Mono", ui-monospace, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 1px solid var(--border);
  background: var(--bg3);
  color: var(--text);
  padding: 0.55rem 1rem;
  border-radius: 10px;
  cursor: pointer;
  transition: 0.15s ease;
  white-space: nowrap;
}
.btn:hover {
  border-color: #3d4a66;
  background: #222a3d;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}
.btn-primary:hover {
  filter: brightness(1.08);
  background: linear-gradient(135deg, var(--accent), var(--accent2));
}
.btn-danger {
  border-color: rgba(255, 107, 122, 0.4);
  color: var(--danger);
}
.btn-ghost {
  background: transparent;
}
.btn-sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.875rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.9rem;
}
.field label {
  font-size: 0.875rem;
  color: var(--muted);
}
.field input,
.field textarea,
.field select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.65rem 0.8rem;
  outline: none;
}
.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(108, 158, 255, 0.15);
}
.field textarea {
  min-height: 140px;
  resize: vertical;
}
.field textarea.mono,
.mono {
  font-family: var(--mono);
  font-size: 0.9rem;
}

.error-msg {
  color: var(--danger);
  font-size: 0.9rem;
  margin: 0.5rem 0;
  min-height: 1.2em;
}
.ok-msg {
  color: var(--ok);
  font-size: 0.9rem;
}

/* Landing */
.landing {
  min-height: 100vh;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(108, 158, 255, 0.2), transparent),
    radial-gradient(ellipse 50% 40% at 100% 50%, rgba(139, 124, 246, 0.12), transparent),
    var(--bg);
}
.landing-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.2rem 1.5rem;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
  text-decoration: none;
}
.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: grid;
  place-items: center;
  font-size: 1rem;
}
.nav-actions {
  display: flex;
  gap: 0.5rem;
}
.hero {
  max-width: 1100px;
  margin: 0 auto;
  padding: 3rem 1.5rem 4rem;
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 2.5rem;
  align-items: center;
}
.hero h1 {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  line-height: 1.2;
  margin: 0 0 1rem;
}
.hero p.lead {
  color: var(--muted);
  font-size: 1.05rem;
  margin: 0 0 1.5rem;
}
.hero-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}
.feature-grid {
  display: grid;
  gap: 0.75rem;
}
.feature-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
}
.feature-card h3 {
  margin: 0 0 0.3rem;
  font-size: 1rem;
}
.feature-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}
.footer-note {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 2rem 1rem 3rem;
}

/* Auth pages */
.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(ellipse 60% 40% at 50% 0%, rgba(108, 158, 255, 0.15), transparent),
    var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.75rem;
  box-shadow: var(--shadow);
}
.auth-card h1 {
  margin: 0 0 0.25rem;
  font-size: 1.4rem;
}
.auth-card .sub {
  color: var(--muted);
  margin: 0 0 1.25rem;
  font-size: 0.9rem;
}
.auth-card .btn-primary {
  width: 100%;
  margin-top: 0.25rem;
}
.auth-switch {
  text-align: center;
  margin-top: 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}

/* App shell */
.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 220px 1fr;
}
.sidebar {
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1rem 0.75rem;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}
.sidebar .brand {
  padding: 0.4rem 0.5rem 1rem;
}
.sidebar-close {
  display: none;
  flex-shrink: 0;
  margin-top: 0.25rem;
}
.menu-toggle {
  display: none;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}
.topbar-left h2 {
  margin: 0;
  font-size: 1.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-backdrop {
  display: none;
}
.nav-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  color: var(--muted);
  cursor: pointer;
  border: none;
  background: transparent;
  text-align: left;
  width: 100%;
}
.nav-item:hover {
  background: var(--bg3);
  color: var(--text);
}
.nav-item.active {
  background: rgba(108, 158, 255, 0.12);
  color: var(--accent);
  font-weight: 600;
}
.user-box {
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
  margin-top: 0.5rem;
}
.user-name {
  font-size: 0.9rem;
  padding: 0 0.5rem 0.4rem;
  word-break: break-all;
}
.user-email {
  font-size: 0.75rem;
  color: var(--muted);
  padding: 0 0.5rem 0.6rem;
  word-break: break-all;
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: rgba(15, 17, 23, 0.85);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}
.content {
  padding: 1rem 1.25rem 2rem;
  flex: 1;
}

.panel {
  display: none;
}
.panel.active {
  display: block;
}

/* Split layout for notes/snippets */
.split {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1rem;
  min-height: calc(100vh - 120px);
}
.list-pane {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 120px);
}
.list-search {
  padding: 0.65rem;
  border-bottom: 1px solid var(--border);
}
.list-search input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  outline: none;
}
.list-items {
  overflow: auto;
  flex: 1;
}
.list-item {
  width: 100%;
  text-align: left;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  padding: 0.75rem 0.85rem;
  cursor: pointer;
}
.list-item:hover {
  background: var(--bg3);
}
.list-item.active {
  background: rgba(108, 158, 255, 0.1);
  border-left: 3px solid var(--accent);
}
.list-item .t {
  font-weight: 600;
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-item .m {
  color: var(--muted);
  font-size: 0.75rem;
  margin-top: 0.2rem;
}
.empty-list {
  padding: 1.5rem 1rem;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

.editor-pane {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 400px;
}
.editor-pane.empty-state {
  align-items: center;
  justify-content: center;
  color: var(--muted);
}
.editor-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.editor-row input[type="text"],
.editor-row select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  outline: none;
}
.editor-row input.title {
  flex: 1;
  min-width: 160px;
  font-weight: 600;
}
.editor-pane textarea {
  flex: 1;
  min-height: 280px;
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem;
  outline: none;
  resize: vertical;
}
.share-box {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  padding: 0.65rem 0.75rem;
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: 10px;
  font-size: 0.875rem;
}
.share-box code {
  background: var(--bg3);
  padding: 0.15rem 0.4rem;
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 0.8rem;
  word-break: break-all;
}

/* Dashboard */
.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}
.card h3 {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  color: var(--muted);
  font-weight: 600;
}
.card ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.card li {
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
  cursor: pointer;
}
.card li:last-child {
  border-bottom: none;
}
.card li:hover {
  color: var(--accent);
}
.stat-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.stat {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
  min-width: 120px;
}
.stat .n {
  font-size: 1.5rem;
  font-weight: 700;
}
.stat .l {
  color: var(--muted);
  font-size: 0.8rem;
}

/* Transfer */
.transfer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.transfer-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}
.transfer-card h3 {
  margin: 0 0 0.75rem;
}
.code-big {
  font-family: var(--mono);
  font-size: 1.8rem;
  letter-spacing: 0.25em;
  font-weight: 700;
  color: var(--accent);
  text-align: center;
  padding: 0.75rem;
  background: var(--bg);
  border-radius: 10px;
  margin: 0.5rem 0 1rem;
}
.history-list {
  margin-top: 1rem;
}
.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.history-item code {
  font-family: var(--mono);
  color: var(--accent);
}

/* Toast */
#toast {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  background: #243049;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.7rem 1.1rem;
  border-radius: 999px;
  box-shadow: var(--shadow);
  z-index: 100;
  transition: transform 0.25s ease;
  max-width: 90vw;
  font-size: 0.9rem;
}
#toast.show {
  transform: translateX(-50%) translateY(0);
}

/* Share public page */
.share-page {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem 1.25rem 3rem;
}
.share-page .meta {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}
.share-page pre {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--mono);
  font-size: 0.9rem;
}
.share-page .body-text {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Points / shop / plaza */
.points-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(108, 158, 255, 0.25), rgba(139, 124, 246, 0.25));
  border: 1px solid rgba(108, 158, 255, 0.35);
  color: var(--accent);
  font-weight: 700;
  font-size: 0.95rem;
  padding: 0.4rem 0.65rem;
  border-radius: 999px;
  margin: 0 0.5rem 0.5rem;
}
.nav-item.locked {
  opacity: 0.65;
}
.nav-item.locked .lock-tag {
  font-size: 0.75rem;
  color: var(--warn);
}
.shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.85rem;
}
.shop-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.shop-card h3 {
  margin: 0;
  font-size: 1.05rem;
}
.shop-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  flex: 1;
}
.shop-card .price {
  font-weight: 700;
  color: var(--accent);
}
.shop-card.unlocked {
  border-color: rgba(61, 214, 140, 0.35);
}
.shop-card .badge-ok {
  color: var(--ok);
  font-size: 0.85rem;
  font-weight: 600;
}

.plaza-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 1rem;
  align-items: stretch;
}
.plaza-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.65rem;
}
.plaza-toolbar select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.35rem 0.5rem;
  margin-left: 0.35rem;
}
.plaza-status {
  color: var(--muted);
  font-size: 0.85rem;
}
.plaza-canvas-wrap {
  position: relative;
  background: #0c1018;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  line-height: 0;
  touch-action: none;
}
#plaza-canvas {
  display: block;
  max-width: 100%;
  cursor: crosshair;
  touch-action: none;
}
.plaza-joystick {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 5;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.plaza-joy-base {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: rgba(20, 26, 40, 0.72);
  border: 2px solid rgba(108, 158, 255, 0.45);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  position: relative;
  display: grid;
  place-items: center;
}
.plaza-joystick.active .plaza-joy-base {
  border-color: rgba(108, 158, 255, 0.9);
  background: rgba(28, 36, 56, 0.85);
}
.plaza-joy-knob {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: linear-gradient(145deg, #6c9eff, #8b7cf6);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  transform: translate(0, 0);
  will-change: transform;
  pointer-events: none;
}
.plaza-joy-label {
  font-size: 0.7rem;
  color: rgba(232, 236, 244, 0.75);
  text-shadow: 0 1px 2px #000;
  line-height: 1;
}
.plaza-hint {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0.5rem 0 0;
}
@media (min-width: 861px) {
  .plaza-joystick {
    opacity: 0.55;
  }
  .plaza-joystick:hover,
  .plaza-joystick.active {
    opacity: 1;
  }
}
@media (max-width: 860px) {
  .plaza-joy-base {
    width: 120px;
    height: 120px;
  }
  .plaza-joy-knob {
    width: 50px;
    height: 50px;
  }
}
.plaza-side {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  min-height: 420px;
}
.plaza-side h3 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
}
.plaza-chat-log {
  flex: 1;
  overflow: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem;
  margin-bottom: 0.5rem;
  font-size: 0.88rem;
}
.plaza-chat-line {
  margin-bottom: 0.35rem;
  word-break: break-word;
}
.plaza-chat-line strong {
  color: var(--accent);
  margin-right: 0.3rem;
}
#plaza-chat-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  outline: none;
}
.lock-overlay {
  padding: 2rem;
  text-align: center;
  color: var(--muted);
  background: var(--bg2);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

@media (max-width: 860px) {
  .hero {
    grid-template-columns: 1fr;
  }
  .app-shell {
    grid-template-columns: 1fr;
  }

  /* 모바일: 메뉴는 기본 숨김, 슬라이드 드로어 */
  .menu-toggle {
    display: inline-flex;
    flex-shrink: 0;
  }
  .sidebar-close {
    display: inline-flex;
  }
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 40;
    border: none;
    padding: 0;
    margin: 0;
  }
  .sidebar-backdrop[hidden] {
    display: none !important;
  }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: min(86vw, 300px);
    height: 100vh;
    height: 100dvh;
    z-index: 50;
    border-right: 1px solid var(--border);
    border-bottom: none;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 0;
    padding: 0.85rem 0.75rem 1.25rem;
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    box-shadow: 8px 0 30px rgba(0, 0, 0, 0.35);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  body.menu-open .sidebar {
    transform: translateX(0);
  }
  body.menu-open {
    overflow: hidden;
  }
  .sidebar .brand {
    width: auto;
    padding: 0.35rem 0.35rem 0.75rem;
  }
  .nav-list {
    flex-direction: column;
    flex-wrap: nowrap;
    flex: 1;
  }
  .nav-item {
    padding: 0.7rem 0.75rem;
    font-size: 0.95rem;
  }
  .user-box {
    border-top: 1px solid var(--border);
    margin-top: 0.5rem;
    padding-top: 0.75rem;
    width: 100%;
    display: block;
  }
  .user-name,
  .user-email {
    padding: 0 0.5rem 0.35rem;
  }
  .topbar {
    padding: 0.75rem 0.85rem;
  }
  .content {
    padding: 0.85rem;
  }
  .split,
  .transfer-grid,
  .plaza-layout {
    grid-template-columns: 1fr;
  }
  .list-pane {
    max-height: 220px;
  }
  .plaza-side {
    min-height: 240px;
  }
}
