/* ===== Design Tokens ===== */
:root {
  --bg-primary: #0f0f1a;
  --bg-card: #161625;
  --bg-item: #1a1a30;
  --bg-item-hover: #1e1e38;
  --accent-gold: #e8b04a;
  --accent-gold-light: #f0c868;
  --accent-gold-dim: #b8924a;
  --accent-cyan: #4ac8e8;
  --accent-purple: #a04ae8;
  --accent-green: #4ae868;
  --accent-complete: #4ae868;
  --text-primary: #e8e8f0;
  --text-secondary: #8888a0;
  --text-muted: #555568;
  --border: #2a2a40;
  --border-accent: #3a3a55;
  --danger: #e05555;
  --radius-sm: 6px;
  --radius-md: 12px;
}

/* ===== Reset ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Pretendard Variable', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  padding: 16px 32px;
  display: flex;
  flex-direction: column;
}

/* ===== Header ===== */

header {
  text-align: center;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  position: relative;
  width: 100%;
}

header::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 50%;
  transform: translateX(-50%);
  width: 160px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-gold), transparent);
}

.header-inner {
  margin-bottom: 8px;
}

header h1 {
  font-size: 2rem;
  color: var(--accent-gold);
  margin-bottom: 4px;
  text-shadow: 0 0 24px rgba(232, 176, 74, 0.35);
  letter-spacing: -0.02em;
}

.reset-info {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ===== Overall Progress ===== */

.overall-progress-wrap {
  max-width: 400px;
  margin: 8px auto 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.overall-progress-bar {
  flex: 1;
  height: 8px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
  overflow: hidden;
}

.overall-progress-fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--accent-gold), var(--accent-gold-light));
  transition: width 0.4s ease, background 0.4s ease;
  width: 0;
}

.overall-progress-fill.complete {
  background: linear-gradient(90deg, var(--accent-complete), #68f088);
  box-shadow: 0 0 12px rgba(74, 232, 104, 0.4);
}

.overall-progress-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
  min-width: 40px;
  text-align: right;
}

.overall-progress-label.complete {
  color: var(--accent-complete);
}

/* ===== Layout ===== */

.layout-wrap {
  display: flex;
  gap: 24px;
  width: 100%;
  align-items: flex-start;
  flex: 1;
}

main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ===== Dungeon Panel ===== */

.dungeon-panel {
  flex: 1;
  min-width: 0;
  display: block;
}

/* ===== Cards ===== */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s, border-color 0.2s;
}

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

/* Category accent line */
.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
}

.card[data-section="todo"]::before {
  background: linear-gradient(90deg, var(--accent-gold), transparent);
}

.card[data-section="daily"]::before {
  background: linear-gradient(90deg, var(--accent-cyan), transparent);
}

.card[data-section="weekly"]::before {
  background: linear-gradient(90deg, var(--accent-purple), transparent);
}

.card[data-section="event"]::before {
  background: linear-gradient(90deg, var(--accent-green), transparent);
}

.card[data-section="dungeon"]::before {
  background: linear-gradient(90deg, var(--accent-gold), transparent);
}

/* Card header */
.card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.card-icon {
  font-size: 1rem;
}

.card-header h2 {
  font-size: 1rem;
  margin: 0;
  flex: 1;
  font-weight: 600;
}

.card-header h2 small {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 400;
}

/* Category-specific heading colors */
.card[data-section="todo"] .card-header h2 { color: var(--accent-gold); }
.card[data-section="daily"] .card-header h2 { color: var(--accent-cyan); }
.card[data-section="weekly"] .card-header h2 { color: var(--accent-purple); }
.card[data-section="event"] .card-header h2 { color: var(--accent-green); }
.card[data-section="dungeon"] .card-header h2 { color: var(--accent-gold); }

.quest-count {
  font-size: 0.78rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
}

.btn-reorder {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  line-height: 1.2;
}

.btn-reorder:hover {
  border-color: var(--accent-gold);
  color: var(--accent-gold);
}

.btn-reorder.active {
  background: var(--accent-gold);
  color: var(--bg-primary);
  border-color: var(--accent-gold);
}

.btn-dungeon-reset {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}

.btn-dungeon-reset:hover {
  border-color: var(--accent-gold);
  color: var(--accent-gold);
  background: rgba(232, 176, 74, 0.08);
}

/* ===== Progress bar ===== */

.progress-bar-wrap {
  height: 6px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
  margin-bottom: 10px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease, background 0.4s ease;
  width: 0;
}

/* Category-specific progress colors */
.card[data-section="todo"] .progress-bar-fill {
  background: linear-gradient(90deg, var(--accent-gold), var(--accent-gold-light));
}

.card[data-section="daily"] .progress-bar-fill {
  background: linear-gradient(90deg, var(--accent-cyan), #68e0f0);
}

.card[data-section="weekly"] .progress-bar-fill {
  background: linear-gradient(90deg, var(--accent-purple), #c068f0);
}

.card[data-section="event"] .progress-bar-fill {
  background: linear-gradient(90deg, var(--accent-green), #68f088);
}

.card[data-section="dungeon"] .progress-bar-fill {
  background: linear-gradient(90deg, var(--accent-gold), var(--accent-gold-light));
}

/* 100% complete effect */
.progress-bar-fill.complete {
  background: linear-gradient(90deg, var(--accent-complete), #68f088) !important;
  box-shadow: 0 0 8px rgba(74, 232, 104, 0.3);
  animation: progressPulse 2s ease-in-out infinite;
}

@keyframes progressPulse {
  0%, 100% { box-shadow: 0 0 8px rgba(74, 232, 104, 0.3); }
  50% { box-shadow: 0 0 14px rgba(74, 232, 104, 0.5); }
}

/* ===== Quest list ===== */

.quest-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.quest-item {
  background: var(--bg-item);
  border-radius: var(--radius-sm);
  border-left: 3px solid transparent;
  transition: opacity 0.2s, background 0.15s, border-color 0.15s;
}

.quest-item-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
}

/* Category-specific hover border */
.card[data-section="todo"] > .quest-list > .quest-item:hover,
.card[data-section="todo"] .quest-children > .quest-item:hover { border-left-color: var(--accent-gold); }
.card[data-section="daily"] > .quest-list > .quest-item:hover,
.card[data-section="daily"] .quest-children > .quest-item:hover { border-left-color: var(--accent-cyan); }
.card[data-section="weekly"] > .quest-list > .quest-item:hover,
.card[data-section="weekly"] .quest-children > .quest-item:hover { border-left-color: var(--accent-purple); }
.card[data-section="event"] > .quest-list > .quest-item:hover,
.card[data-section="event"] .quest-children > .quest-item:hover { border-left-color: var(--accent-green); }
.card[data-section="dungeon"] .quest-item:hover { border-left-color: var(--accent-gold); }

.quest-item:hover {
  background: var(--bg-item-hover);
}

.quest-item.done {
  opacity: 0.45;
}

.quest-item.done > .quest-item-row .quest-name {
  text-decoration: line-through;
  color: #666;
}

/* ===== Toggle & Children ===== */

.btn-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.65rem;
  cursor: pointer;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color 0.2s, transform 0.2s;
  padding: 0;
}

.btn-toggle:hover {
  color: var(--text-primary);
}

.btn-toggle.expanded {
  transform: rotate(90deg);
}

.toggle-spacer {
  width: 18px;
  flex-shrink: 0;
}

.quest-children {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px 0 4px 28px;
}

.btn-add-child {
  background: none;
  border: none;
  color: var(--accent-gold-dim);
  font-size: 1rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.2s;
}

.quest-item-row:hover .btn-add-child {
  opacity: 0.6;
}

.btn-add-child:hover {
  opacity: 1 !important;
  color: var(--accent-gold);
}

.sub-add-form {
  display: flex;
  gap: 6px;
  padding: 4px 6px;
}

.sub-add-form input {
  flex: 1;
  padding: 5px 8px;
  background: var(--bg-item);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.8rem;
  outline: none;
  transition: border-color 0.2s;
}

.sub-add-form input:focus {
  border-color: var(--accent-gold);
}

.sub-add-form input::placeholder {
  color: var(--text-muted);
}

.sub-add-form button {
  width: 28px;
  height: 28px;
  background: var(--accent-gold);
  color: var(--bg-primary);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s;
}

.sub-add-form button:hover {
  background: var(--accent-gold-light);
}

/* ===== Custom Checkbox ===== */

.custom-checkbox {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.custom-checkbox:hover {
  border-color: var(--accent-gold);
}

.custom-checkbox.checked {
  background: var(--accent-gold);
  border-color: var(--accent-gold);
  animation: checkBounce 0.25s ease;
}

.custom-checkbox.checked::after {
  content: '\2713';
  color: var(--bg-primary);
  font-size: 0.75rem;
  font-weight: 700;
}

@keyframes checkBounce {
  0% { transform: scale(1); }
  40% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* ===== Drag ===== */

.drag-handle {
  cursor: grab;
  color: #666;
  font-size: 1rem;
  user-select: none;
  flex-shrink: 0;
}

.drag-handle:active {
  cursor: grabbing;
}

.quest-item.dragging {
  opacity: 0.4;
  background: #2a2a5a;
}

.quest-item.drag-over {
  border-top: 2px solid var(--accent-gold);
  margin-top: -2px;
}

/* ===== Quest name & edit ===== */

.quest-name {
  flex: 1;
  font-size: 0.9rem;
  word-break: break-word;
  cursor: default;
}

.quest-edit-input {
  flex: 1;
  padding: 2px 6px;
  background: var(--bg-primary);
  border: 1px solid var(--accent-gold);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 0.9rem;
  outline: none;
}

/* ===== Delete button ===== */

.btn-delete {
  background: none;
  border: none;
  color: var(--danger);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  opacity: 0;
  transition: opacity 0.2s;
}

.quest-item-row:hover .btn-delete {
  opacity: 0.6;
}

.btn-delete:hover {
  opacity: 1 !important;
}

/* ===== Add form ===== */

.add-form {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.add-form input {
  flex: 1;
  padding: 8px 12px;
  background: var(--bg-item);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.add-form input:focus {
  border-color: var(--accent-gold);
  box-shadow: 0 0 8px rgba(232, 176, 74, 0.15);
}

.add-form input::placeholder {
  color: var(--text-muted);
}

.btn-add {
  width: 36px;
  height: 36px;
  background: var(--accent-gold);
  color: var(--bg-primary);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1.3rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-add:hover {
  background: var(--accent-gold-light);
  transform: scale(1.05);
}

/* ===== Empty state ===== */

.empty-msg {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.82rem;
  padding: 16px 0;
}

.empty-icon {
  font-size: 1.5rem;
  display: block;
  margin-bottom: 4px;
  opacity: 0.5;
}

/* ===== Quest add/remove animations ===== */

@keyframes questFadeIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.quest-item.fade-in {
  animation: questFadeIn 0.25s ease;
}

/* ===== Sync Button (Header) ===== */

.btn-sync {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  margin-top: 6px;
}

.btn-sync:hover {
  border-color: var(--accent-gold);
  color: var(--accent-gold);
  background: rgba(232, 176, 74, 0.08);
}

/* ===== Sync Modal ===== */

.sync-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.sync-overlay.active {
  display: flex;
}

.sync-modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
  width: 420px;
  max-width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}

.sync-modal::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent-gold), var(--accent-gold-light), transparent);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.sync-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.sync-header h3 {
  font-size: 1.1rem;
  color: var(--accent-gold);
  font-weight: 600;
}

.sync-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  transition: color 0.2s;
}

.sync-close:hover {
  color: var(--danger);
}

.sync-section {
  margin-bottom: 16px;
}

.sync-section h4 {
  font-size: 0.9rem;
  color: var(--text-primary);
  margin-bottom: 6px;
  font-weight: 600;
}

.sync-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 10px;
  line-height: 1.4;
}

.sync-divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

.sync-input-row {
  display: flex;
  gap: 8px;
}

.sync-input-row input {
  flex: 1;
  padding: 8px 12px;
  background: var(--bg-item);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-family: 'Consolas', 'Monaco', monospace;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  outline: none;
  transition: border-color 0.2s;
}

.sync-input-row input:focus {
  border-color: var(--accent-gold);
}

.sync-input-row input::placeholder {
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: normal;
  font-family: 'Pretendard Variable', sans-serif;
}

.btn-sync-action {
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-sync-primary {
  background: var(--accent-gold);
  color: var(--bg-primary);
}

.btn-sync-primary:hover {
  background: var(--accent-gold-light);
  transform: scale(1.02);
}

.btn-sync-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.sync-code-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 12px;
  padding: 16px;
  background: var(--bg-item);
  border: 1px solid var(--accent-gold-dim);
  border-radius: var(--radius-sm);
}

.sync-code-text {
  font-size: 2rem;
  font-family: 'Consolas', 'Monaco', monospace;
  font-weight: 700;
  color: var(--accent-gold);
  letter-spacing: 0.3em;
  text-shadow: 0 0 16px rgba(232, 176, 74, 0.3);
}

.btn-sync-copy {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 1rem;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  line-height: 1;
}

.btn-sync-copy:hover {
  border-color: var(--accent-gold);
  color: var(--accent-gold);
}

.sync-status {
  font-size: 0.8rem;
  text-align: center;
  padding: 4px 0;
  min-height: 24px;
  transition: color 0.2s;
}

.sync-status-success {
  color: var(--accent-green);
}

.sync-status-error {
  color: var(--danger);
}

.sync-info {
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.sync-info p {
  font-size: 0.7rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ===== Footer ===== */

footer {
  text-align: center;
  padding: 24px 0 8px;
  margin-top: 32px;
  border-top: 1px solid var(--border);
  width: 100%;
}

footer p {
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.footer-credit {
  margin-top: 4px;
}

.footer-credit a {
  color: var(--accent-gold-dim);
  text-decoration: none;
  transition: color 0.2s;
}

.footer-credit a:hover {
  color: var(--accent-gold);
}
