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

:root {
  /* Colors */
  --bg: #0b0c10;
  --panel: #13151b;
  --panel-lighter: #1a1d26;
  --border: #2a2f3d;
  --border-hover: #3e4559;

  --accent: #86ff7b;
  --accent-2: #73b8ff;
  --accent-glow: rgba(134, 255, 123, 0.2);

  --text: #e7ecf4;
  --text-muted: #9aa3b5;
  --text-dim: #636b7c;

  --shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
  --radius: 16px;

  --trans-fast: 150ms ease;
  --trans-med: 250ms ease;

  font-family: "Space Grotesk", system-ui, -apple-system, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  background-image: radial-gradient(
      circle at 15% 15%,
      rgba(134, 255, 123, 0.05),
      transparent 40%
    ),
    radial-gradient(
      circle at 85% 10%,
      rgba(115, 184, 255, 0.08),
      transparent 40%
    );
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding: 32px 48px;
}

.page {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 24px;
}

/* --- Hero Section --- */
.hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 32px;
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.eyebrow {
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 13px;
  font-weight: 700;
  margin: 0 0 8px;
}

.hero h1 {
  margin: 0 0 12px;
  font-size: 36px;
  background: linear-gradient(135deg, #fff 30%, #9aa3b5 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.lede {
  margin: 0;
  color: var(--text-muted);
  font-size: 16px;
  max-width: 480px;
}

/* Usage Card */
.hero-usage {
  flex-shrink: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  min-width: 380px;
}

.usage-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.date-badge {
  font-size: 11px;
  color: var(--text-dim);
  font-feature-settings: "tnum";
}

.badge {
  background: rgba(134, 255, 123, 0.1);
  color: var(--accent);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 99px;
  border: 1px solid rgba(134, 255, 123, 0.2);
}

.usage-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.usage-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.usage-item .label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
}

.usage-item strong {
  font-size: 14px;
  font-feature-settings: "tnum";
}

.text-accent-2 {
  color: var(--accent-2);
}

.usage-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 14px;
}

.cost-value {
  color: var(--accent);
  font-size: 16px;
}

/* --- Layout Grid --- */
.layout-grid {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 24px;
  align-items: start;
}

/* New Layout V2: Top row (1:1) + Bottom row (full width) */
.layout-grid-v2 {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.top-row {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 24px;
  min-height: 500px;
  position: relative;
}

.top-row .config-panel {
  height: auto;
}

.top-row .config-panel .panel {
  height: auto;
  overflow: visible;
  display: flex;
  flex-direction: column;
}

.top-row .catalog-panel {
  width: 100%;
  position: relative;
  height: auto;
}

.top-row .catalog-panel .panel {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  height: auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.top-row .catalog-panel .catalog-content-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.result-panel-full {
  width: 100%;
}

.result-panel-full .routine-output {
  min-height: 200px;
}

@media (max-width: 1024px) {
  .layout-grid {
    grid-template-columns: 1fr;
  }
  .top-row {
    grid-template-columns: 1fr;
    height: calc(100vh - 140px);
    min-height: 500px;
  }
}

@media (max-width: 768px) {
  .hero {
    flex-direction: column;
    align-items: flex-start;
  }
  .hero-usage {
    width: 100%;
    min-width: 0;
  }
  body {
    padding: 16px;
  }
}

/* --- Panels --- */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.panel-head {
  margin-bottom: 24px;
}

.panel-head h2 {
  margin: 0 0 6px;
  font-size: 20px;
}

.panel-head p {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
}

.sidebar-column {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.row-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* --- Form --- */
.form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.field-label,
.field > label,
.label-row > label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-muted);
}

/* Radio Cards */
.radio-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.radio-card {
  position: relative;
  cursor: pointer;
}

.radio-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.radio-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  background: var(--panel-lighter);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: var(--trans-fast);
  font-weight: 500;
}

.radio-card input:checked + .radio-content {
  background: rgba(134, 255, 123, 0.1);
  border-color: var(--accent);
  color: var(--accent);
}

/* Grid Fields */
.grid-2-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* Select & Inputs */
.select-wrapper {
  position: relative;
}

.select-wrapper::after {
  content: "▼";
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  color: var(--text-muted);
  pointer-events: none;
}

select,
.input-text {
  width: 100%;
  background: var(--panel-lighter);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 15px;
  appearance: none;
  transition: var(--trans-fast);
}

select:focus,
.input-text:focus {
  outline: none;
  border-color: var(--accent-2);
}

/* Range Input */
.label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.value-badge {
  background: var(--accent);
  color: #000;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 13px;
}

input[type="range"] {
  width: 100%;
  background: transparent;
  appearance: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  background: var(--border);
  height: 6px;
  border-radius: 3px;
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  background: var(--accent);
  width: 18px;
  height: 18px;
  margin-top: -6px;
  border-radius: 50%;
  box-shadow: 0 0 0 4px var(--panel);
}

/* Split Input */
.split-input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Buttons */
.btn-primary {
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none;
  border-radius: 12px;
  color: #0b0c10;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  transition: var(--trans-fast);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(134, 255, 123, 0.25);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  filter: grayscale(0.5);
}

.action-meta {
  margin-top: 12px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

/* --- Catalog & Filters --- */
.sub-text {
  font-size: 13px;
  color: var(--text-muted);
}

.btn-icon-text {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: var(--trans-fast);
}

.btn-icon-text:hover {
  background: var(--panel-lighter);
  color: var(--text);
  border-color: var(--text-muted);
}

.btn-icon-text .chevron {
  font-size: 10px;
  transition: transform var(--trans-med);
}

.btn-icon-text.active .chevron {
  transform: rotate(180deg);
}

.filter-section.panel {
  background: rgba(19, 21, 27, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 24px;
  transition: var(--trans-med);
}

.filter-section.hidden {
  display: none;
}

.filters {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 50px;
}

.filter-label {
  font-size: 12px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 8px;
  font-weight: 600;
}

.scrollable-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 120px;
  overflow-y: auto;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  transition: var(--trans-fast);
}

.filter-chip:hover {
  background: rgba(255, 255, 255, 0.08);
}

.filter-chip input {
  accent-color: var(--accent);
}

.filter-chip input:checked + span {
  color: var(--text);
}

.filter-chip:has(input:checked) {
  background: rgba(115, 184, 255, 0.08);
  border-color: rgba(115, 184, 255, 0.4);
  color: var(--text);
}

/* Filter Presets */
.filter-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.preset-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--panel-lighter);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--trans-fast);
}

.preset-btn:hover {
  background: rgba(134, 255, 123, 0.1);
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}

.preset-btn.active {
  background: rgba(134, 255, 123, 0.2);
  border-color: var(--accent);
  color: var(--accent);
}

.preset-btn.preset-reset {
  background: transparent;
  border-style: dashed;
}

.preset-btn.preset-reset:hover {
  background: rgba(255, 107, 107, 0.1);
  border-color: #ff6b6b;
  color: #ff6b6b;
}

/* Filter Summary */
.filter-summary {
  font-size: 12px;
  color: var(--text-dim);
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  margin-bottom: 16px;
  min-height: 32px;
  display: flex;
  align-items: center;
}

.filter-summary:empty::before {
  content: "전체 선택";
  color: var(--text-dim);
  opacity: 0.5;
}

.filter-summary .summary-label {
  color: var(--accent-2);
  font-weight: 600;
}

.filter-summary .summary-count {
  color: var(--accent);
  font-weight: 700;
}

/* Tool Icons in chips */
.filter-chip .tool-icon {
  font-size: 14px;
  margin-right: 2px;
}

/* Exercise Count Bar */
.exercise-count-bar {
  display: flex;
  flex-wrap: wrap; /* allow wrapping on small screens */
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  margin-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
}

.count-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge-count {
  background: var(--accent);
  color: #000;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 13px;
}

/* Catalog Controls */
.catalog-controls {
  display: flex;
  align-items: center;
  gap: 16px;
}

.view-toggle-group {
  display: flex;
  background: var(--panel-lighter);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
}

.view-btn {
  background: transparent;
  border: none;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  border-radius: 6px;
  cursor: pointer;
}

.view-btn.active {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  font-weight: 600;
}

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

.action-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.action-btn:hover {
  background: var(--panel-lighter);
  color: var(--text);
  border-color: var(--text-muted);
}

.catalog-list {
  flex: 1 1 0;
  height: 100%;
  overflow-y: auto;
  padding-right: 4px;
  min-height: 0;
}

.catalog-group h4 {
  color: var(--accent-2);
  font-size: 13px;
  margin: 12px 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill-item {
  font-size: 12px;
  background: var(--panel-lighter);
  padding: 4px 10px;
  border-radius: 6px;
  color: var(--text-muted);
  border: 1px solid var(--border);
  transition: var(--trans-fast);
  cursor: pointer;
}

.pill-item:hover {
  border-color: var(--accent-2);
  color: var(--text);
}

.pill-item.inactive {
  opacity: 0.3;
  text-decoration: line-through;
  filter: grayscale(1);
  border-color: transparent;
  background: transparent;
}

/* --- Result Panel --- */
.h-full {
  height: 100%;
  min-height: 500px;
}

.hero-usage {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: rgba(0, 0, 0, 0.3);
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  min-width: auto;
  height: fit-content;
}

.usage-grid {
  display: flex;
  gap: 24px;
  align-items: center;
}

.usage-item:nth-child(2),
.usage-item:nth-child(3),
.usage-item:nth-child(4) {
  display: none;
}

@media (min-width: 1024px) {
  .usage-item:nth-child(2),
  .usage-item:nth-child(3),
  .usage-item:nth-child(4) {
    display: flex;
  }
}
.lang-toggle {
  display: flex;
  background: var(--panel-lighter);
  padding: 2px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.lang-btn {
  background: transparent;
  border: none;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: 6px;
  cursor: pointer;
}

.lang-btn.active {
  background: var(--text);
  color: var(--bg);
}

.routine-output {
  min-height: 300px;
  margin-bottom: 24px;
}

.routine-output.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.01);
}

.empty-state {
  text-align: center;
  color: var(--text-dim);
}

.routine-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px;
  align-items: start;
  justify-content: center;
  max-width: 100%;
}

@media (max-width: 1400px) {
  .routine-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 1024px) {
  .routine-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .routine-grid {
    grid-template-columns: 1fr;
  }
}

.routine-day {
  background: rgba(26, 29, 38, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  overflow: hidden;
  height: 100%;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.routine-day:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  border-color: var(--accent);
}

.routine-day h3 {
  background: var(--panel-lighter);
  padding: 16px 20px;
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
}

.routine-day h3::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
  margin-right: 12px;
  box-shadow: 0 0 10px var(--accent-glow);
}

.routine-day ul {
  margin: 0;
  padding: 16px 16px 16px 16px;
  color: var(--text-muted);
  list-style: none;
}

.routine-day li + li {
  margin-top: 6px;
}

.body-part-badge {
  display: inline-block;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 3px 7px;
  border-radius: 4px;
  margin-right: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Body part specific colors */
.body-part-badge[data-body-part="chest"] {
  background: rgba(255, 107, 107, 0.15);
  color: #ff9999;
  border-color: rgba(255, 107, 107, 0.3);
}

.body-part-badge[data-body-part="back"] {
  background: rgba(78, 205, 196, 0.15);
  color: #7dd3c0;
  border-color: rgba(78, 205, 196, 0.3);
}

.body-part-badge[data-body-part="shoulder"] {
  background: rgba(255, 195, 113, 0.15);
  color: #ffb366;
  border-color: rgba(255, 195, 113, 0.3);
}

.body-part-badge[data-body-part="arm"] {
  background: rgba(162, 155, 254, 0.15);
  color: #a99bfe;
  border-color: rgba(162, 155, 254, 0.3);
}

.body-part-badge[data-body-part="leg"] {
  background: rgba(134, 255, 123, 0.15);
  color: #86ff7b;
  border-color: rgba(134, 255, 123, 0.3);
}

.body-part-badge[data-body-part="abs"] {
  background: rgba(255, 159, 243, 0.15);
  color: #ff9ff3;
  border-color: rgba(255, 159, 243, 0.3);
}

.body-part-badge[data-body-part="cardio"] {
  background: rgba(115, 184, 255, 0.15);
  color: #73b8ff;
  border-color: rgba(115, 184, 255, 0.3);
}

/* Debug Details */
.debug-details details {
  margin-top: 8px;
  background: #000;
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 8px;
}

.debug-details summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--text-dim);
  font-family: monospace;
}

.debug-details pre {
  margin-top: 8px;
  color: var(--accent-2);
  font-size: 12px;
  white-space: pre-wrap;
  max-height: 200px;
  overflow: auto;
}

/* Utility */
.hidden {
  display: none !important;
}

/* Catalog Toggle helpers */
.collapsed {
  display: none !important;
}

#catalog-arrow {
  display: inline-block;
  font-size: 0.8em;
}

/* Catalog Stats */
.catalog-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  margin-left: 12px;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.stat-separator {
  color: var(--text-dim);
  opacity: 0.5;
}

.stat-selected .stat-count {
  color: var(--accent-2);
  font-weight: 700;
}

.stat-excluded .stat-count {
  color: #ff6b6b;
  font-weight: 700;
}

.radio-group-4 {
  grid-template-columns: 1fr 1fr;
}

/* Training Goal Cards - Vertical layout for better fit */
.radio-group-4 .radio-content {
  flex-direction: column;
  gap: 4px;
  padding: 10px 8px;
  font-size: 13px;
}

.radio-group-4 .radio-content .icon {
  font-size: 20px;
}

/* Ensure catalog stays within bounds */
.catalog {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden; /* Crucial for scrolling */
}

/* --- Custom Scrollbar --- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

::-webkit-scrollbar-corner {
  background: transparent;
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
/* Access Control */
.access-control-wrapper {
  background: var(--panel);
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.access-label {
  display: block;
  font-size: 14px;
  color: var(--accent-2);
  margin-bottom: 4px;
  font-weight: 600;
}

.access-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.access-input {
  background: transparent;
  border: none;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  width: 140px;
  outline: none;
}

.access-input::placeholder {
  color: var(--text-dim);
}

.access-btn {
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.access-btn:hover {
  background: rgba(134, 255, 123, 0.1);
}

.access-status {
  font-size: 14px;
}
