:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-muted: #f1f3f9;
  --surface-hover: #f8f9fc;
  --border: #e3e7f0;
  --border-strong: #cdd4e3;
  --text: #151926;
  --text-secondary: #525d73;
  --text-muted: #8490a7;

  --primary: #f59e0b;
  --primary-strong: #d97706;
  --primary-soft: #fef3c7;

  --blue: #2563eb;
  --blue-soft: #dbeafe;
  --blue-border: #93c5fd;

  --green: #059669;
  --green-soft: #d1fae5;
  --green-border: #6ee7b7;

  --red: #dc2626;
  --red-soft: #fee2e2;

  --sun-color: #e11d48;
  --sat-color: #2563eb;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 6px 20px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 18px 40px rgba(15, 23, 42, 0.16);
  --radius: 14px;
  --radius-sm: 9px;
}

[data-theme="dark"] {
  --bg: #0c0f17;
  --surface: #141925;
  --surface-muted: #1b2232;
  --surface-hover: #21293c;
  --border: #252e42;
  --border-strong: #34415c;
  --text: #f1f5f9;
  --text-secondary: #9aa7bd;
  --text-muted: #6b7892;

  --primary: #f59e0b;
  --primary-strong: #fbbf24;
  --primary-soft: rgba(245, 158, 11, 0.16);

  --blue: #60a5fa;
  --blue-soft: rgba(59, 130, 246, 0.18);
  --blue-border: rgba(96, 165, 250, 0.45);

  --green: #34d399;
  --green-soft: rgba(16, 185, 129, 0.18);
  --green-border: rgba(52, 211, 153, 0.45);

  --red: #f87171;
  --red-soft: rgba(239, 68, 68, 0.16);

  --sun-color: #fb7185;
  --sat-color: #60a5fa;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.6);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, Roboto, sans-serif;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

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

.hidden {
  display: none !important;
}

/* App Layout */
.app-shell {
  max-width: 1640px;
  margin: 0 auto;
  padding: 16px 20px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  box-shadow: var(--shadow-sm);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
}

.brand-badge {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--primary-soft);
  border: 1px solid rgba(245, 158, 11, 0.35);
  display: grid;
  place-items: center;
  font-size: 20px;
}

.brand-title {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.month-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-muted);
  padding: 4px 6px;
  border-radius: 11px;
  border: 1px solid var(--border);
}

.month-picker-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.month-label {
  font-size: 16px;
  font-weight: 800;
  padding: 4px 10px;
  cursor: pointer;
  border-radius: 8px;
  letter-spacing: -0.02em;
}

.month-label:hover {
  background: var(--surface);
}

.month-picker-hidden {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-weight: 600;
  font-size: 13px;
  padding: 8px 14px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.98);
}

.btn-sm {
  padding: 6px 11px;
  font-size: 12px;
  border-radius: 8px;
}

.btn-full {
  width: 100%;
}

.btn-primary {
  background: var(--primary);
  color: #111827;
  font-weight: 700;
}

.btn-primary:hover {
  background: var(--primary-strong);
  color: #fff;
}

.btn-ghost {
  background: var(--surface-muted);
  border-color: var(--border);
  color: var(--text);
}

.btn-ghost:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  background: var(--surface-muted);
  border-color: var(--border);
  font-size: 13px;
}

.btn-icon:hover {
  background: var(--surface);
  border-color: var(--border-strong);
}

.btn-danger {
  background: var(--red-soft);
  color: var(--red);
  border-color: rgba(220, 38, 38, 0.25);
}

.btn-danger:hover {
  background: var(--red);
  color: #fff;
}

/* KPI Strip */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
}

.kpi-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.kpi-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.kpi-value {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.kpi-unit,
.kpi-sub {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-left: 2px;
}

.kpi-pct {
  font-size: 12px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
}

.badge-blue {
  background: var(--blue-soft);
  color: var(--blue);
}

.badge-green {
  background: var(--green-soft);
  color: var(--green);
}

.progress-track {
  height: 6px;
  border-radius: 999px;
  background: var(--surface-muted);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.25s ease;
}

.fill-blue {
  background: var(--blue);
}

.fill-green {
  background: var(--green);
}

/* Mobile Tabs */
.mobile-tabs {
  display: none;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.mobile-tab {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}

.mobile-tab.active {
  background: var(--primary);
  color: #111827;
  border-color: var(--primary);
}

/* Main Split Workspace */
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.95fr) minmax(330px, 1fr);
  gap: 16px;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.panel-title-group h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
}

.hint-text {
  display: block;
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.status-legend {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11.5px;
  color: var(--text-secondary);
  font-weight: 600;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
}

.dot-planned {
  background: var(--primary);
}

.dot-produced {
  background: var(--blue);
}

.dot-uploaded {
  background: var(--green);
}

/* Calendar Grid */
.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  border-bottom: 1px solid var(--border);
  background: var(--surface-muted);
}

.weekday {
  text-align: center;
  padding: 8px 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
}

.weekday.sun {
  color: var(--sun-color);
}

.weekday.sat {
  color: var(--sat-color);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.day-cell {
  min-height: 136px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 7px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--surface);
  transition: background 0.15s ease;
  position: relative;
}

.day-cell:nth-child(7n) {
  border-right: none;
}

.day-cell.other-month {
  background: var(--surface-muted);
  opacity: 0.62;
}

.day-cell.today {
  background: rgba(245, 158, 11, 0.06);
  box-shadow: inset 0 0 0 1.5px var(--primary);
}

.day-cell.drag-over {
  background: var(--primary-soft);
  box-shadow: inset 0 0 0 2px var(--primary);
}

.day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.day-num-wrap {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.day-num {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-secondary);
}

.day-cell.sun .day-num {
  color: var(--sun-color);
}

.day-cell.sat .day-num {
  color: var(--sat-color);
}

.today-badge {
  font-size: 10px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--primary);
  color: #111827;
}

.day-add-btn {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-muted);
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  opacity: 0.65;
  transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.day-cell:hover .day-add-btn,
.day-add-btn:focus-visible {
  opacity: 1;
}

.day-add-btn:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: #111827;
}

.day-items {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

/* Schedule Card inside Calendar Cell */
.schedule-card {
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: 8px;
  background: var(--surface-hover);
  padding: 6px 7px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 5px;
  transition: transform 0.12s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.schedule-card:hover {
  box-shadow: var(--shadow-sm);
  border-color: var(--border-strong);
}

.schedule-card.is-produced {
  border-left-color: var(--blue);
  background: var(--blue-soft);
}

.schedule-card.is-uploaded {
  border-left-color: var(--green);
  background: var(--green-soft);
}

.schedule-card.dragging {
  opacity: 0.45;
}

.schedule-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 4px;
}

.schedule-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.schedule-card.is-uploaded .schedule-title {
  text-decoration: none;
}

.platform-tag {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.schedule-checks {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.mini-check {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  transition: all 0.12s ease;
}

.mini-check input {
  width: 12px;
  height: 12px;
  margin: 0;
  accent-color: var(--blue);
  cursor: pointer;
}

.mini-check.upload-check input {
  accent-color: var(--green);
}

.mini-check.checked-produced {
  background: var(--blue);
  border-color: var(--blue);
  color: #ffffff;
}

.mini-check.checked-produced input {
  accent-color: #ffffff;
}

.mini-check.checked-uploaded {
  background: var(--green);
  border-color: var(--green);
  color: #ffffff;
}

.mini-check.checked-uploaded input {
  accent-color: #ffffff;
}

.card-extra-icons {
  margin-left: auto;
  display: inline-flex;
  gap: 2px;
  font-size: 10.5px;
  opacity: 0.85;
}

/* Memo Panel */
.memo-panel {
  position: sticky;
  top: 16px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 32px);
}

.memo-composer {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--surface-hover);
}

.memo-cat-select,
.memo-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.cat-pill,
.filter-pill {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.12s ease;
}

.cat-pill.active,
.filter-pill.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #111827;
}

.memo-composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.memo-toolbar {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.memo-list {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  flex: 1;
}

.memo-empty {
  text-align: center;
  padding: 32px 12px;
  color: var(--text-muted);
  font-size: 13px;
}

.memo-card {
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 11px 12px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 7px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.memo-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.memo-card.pinned {
  border-color: rgba(245, 158, 11, 0.55);
  background: rgba(245, 158, 11, 0.04);
}

.memo-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.memo-cat-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--text-secondary);
}

.memo-actions {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.memo-action-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  padding: 3px 6px;
  border-radius: 6px;
  cursor: pointer;
}

.memo-action-btn:hover {
  background: var(--surface-muted);
  color: var(--text);
}

.memo-action-btn.pin-active {
  color: var(--primary-strong);
}

.memo-card-title {
  font-size: 13.5px;
  font-weight: 800;
  color: var(--text);
}

.memo-card-body {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.55;
}

/* Clickable Links inside Memos & Notes */
.auto-link {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--blue);
  background: var(--blue-soft);
  padding: 1px 6px;
  border-radius: 5px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-all;
}

.auto-link:hover {
  filter: brightness(0.95);
}

.link-preview-box {
  margin-top: 6px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  font-size: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.link-preview-label {
  font-weight: 700;
  color: var(--text-muted);
  font-size: 11px;
}

/* Inputs & Forms */
.input,
.textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 9px 11px;
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input-sm {
  padding: 7px 10px;
  font-size: 12.5px;
}

.textarea {
  resize: vertical;
  min-height: 68px;
}

.textarea-memo-composer {
  min-height: 130px;
  line-height: 1.6;
  overflow-y: hidden;
}

.textarea-lg {
  min-height: 320px;
  line-height: 1.65;
  font-size: 14px;
  overflow-y: hidden;
}

.input:focus,
.textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-group label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-secondary);
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
}

.status-check-box-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.status-toggle-card {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-muted);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.status-toggle-card input {
  margin: 0;
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.status-toggle-card.produced input {
  accent-color: var(--blue);
}

.status-toggle-card.uploaded input {
  accent-color: var(--green);
}

.status-toggle-title {
  font-size: 13px;
  font-weight: 800;
}

.status-toggle-sub {
  font-size: 11px;
  color: var(--text-muted);
}

/* Modals & Lock Screen */
.modal-overlay,
.lock-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.58);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 1000;
}

.lock-overlay {
  z-index: 2000;
  background: var(--bg);
}

.modal-card,
.lock-card {
  width: 100%;
  max-width: 540px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal-card-sm {
  max-width: 400px;
}

.modal-card-lg {
  max-width: 760px;
  max-height: 92vh;
  overflow-y: auto;
}

.modal-header-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.modal-date-badge {
  font-size: 12.5px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-strong);
}

.memo-modal-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.lock-card {
  max-width: 380px;
  padding: 28px 24px;
  text-align: center;
}

.lock-icon {
  font-size: 38px;
  margin-bottom: 6px;
}

.lock-card h1 {
  margin: 0 0 6px;
  font-size: 20px;
  font-weight: 800;
}

.lock-desc,
.modal-desc {
  margin: 0 0 18px;
  font-size: 13px;
  color: var(--text-secondary);
}

.lock-form,
.pin-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.form-error {
  margin: 10px 0 0;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--red);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
}

.modal-body {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 6px;
}

.modal-footer-right {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 14px 0;
}

.pin-disable-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Toast */
.toast-container {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 3000;
}

.toast {
  background: #151926;
  color: #ffffff;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  animation: toastIn 0.18s ease;
}

.toast.error {
  background: var(--red);
}

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

/* Responsive Breakpoints */
@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .memo-panel {
    position: static;
    max-height: none;
  }

  .mobile-tabs {
    display: grid;
  }

  .panel:not(.active-panel) {
    display: none;
  }
}

@media (max-width: 780px) {
  .app-shell {
    padding: 10px 10px 24px;
  }

  .kpi-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .day-cell {
    min-height: 98px;
    padding: 5px;
  }

  .form-row-2,
  .status-check-box-group {
    grid-template-columns: 1fr;
  }
}
