:root {
  --bg-app: #f8fafc;
  --card-bg: #ffffff;
  --primary: #4f46e5;
  --primary-soft: #eef2ff;
  --accent: #ec4899;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --radius: 12px;
}

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

body {
  font-family: 'Noto Sans KR', sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  padding: 2rem 1rem;
}

.app-wrapper {
  max-width: 1000px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Common Card Style */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  border: 1px solid var(--border-color);
}

.section-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  letter-spacing: 0.05em;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.badge {
  background: var(--text-main);
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 4px;
  margin-right: 0.75rem;
}

.badge-accent {
  background: var(--accent);
}

.header-date, .header-dday {
  font-weight: 700;
  font-size: 1.25rem;
}

/* Goal Section */
.goal-content input {
  width: 100%;
  border: none;
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  outline: none;
}

/* Main Content Layout */
.main-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1.5rem;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--bg-app);
}

.section-header h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
}

/* Task List */
.task-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px dashed var(--border-color);
}

.task-form-row {
  display: flex;
  gap: 0.5rem;
}

.task-input-field {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 0.9rem;
  outline: none;
}

.task-input-field:focus {
  border-color: var(--primary);
}

.task-select {
  flex: 1;
  padding: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 0.9rem;
  background-color: white;
  outline: none;
}

.add-btn {
  padding: 0.5rem 1rem;
}

.task-items {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 400px;
  overflow-y: auto;
}

.task-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem;
  border-radius: 6px;
  background-color: var(--bg-app);
  border-left: 4px solid transparent;
}

.task-checkbox {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.task-title-text {
  flex: 1;
  font-size: 0.95rem;
  word-break: break-all;
}

.task-item.completed .task-title-text {
  text-decoration: line-through;
  color: var(--text-muted);
}

.task-subject-badge {
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 500;
  color: #fff;
}

.task-delete-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
}

.task-delete-btn:hover {
  color: #ef4444;
}

/* Time Table */
.timeline-box {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
}

.timeline-header {
  display: grid;
  grid-template-columns: 40px repeat(5, 1fr);
  font-size: 0.65rem;
  font-weight: 700;
  text-align: center;
  background: var(--bg-app);
  border-bottom: 1px solid var(--border-color);
  padding: 6px 0;
  color: var(--text-muted);
}

.hour-row {
  display: grid;
  grid-template-columns: 40px 1fr;
  height: 28px;
  border-bottom: 1px solid var(--border-color);
}

.hour-label {
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-app);
  border-right: 1px solid var(--border-color);
}

.minutes-blocks {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
}

.min-block {
  border-right: 1px solid var(--bg-app);
  cursor: pointer;
  transition: background 0.2s;
}

.min-block:hover {
  background-color: var(--primary-soft);
}

.min-block.filled {
  background-color: var(--primary);
}

/* Footer Section */
.app-footer {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 1.5rem;
}

.time-display {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--text-main);
  text-align: center;
}

.reflection textarea {
  width: 100%;
  min-height: 120px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1rem;
  font-family: inherit;
  font-size: 0.95rem;
  resize: vertical;
  outline: none;
}

.reflection textarea:focus {
  border-color: var(--primary);
}

@media (max-width: 768px) {
  .main-layout, .app-footer {
    grid-template-columns: 1fr;
  }
}

/* Settings Page Styles */
.header-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.icon-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border-radius: 50%;
  transition: background 0.2s;
}

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

.header-title {
  font-weight: 700;
  font-size: 1.25rem;
}

.settings-main {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.section-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.subject-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.form-input:focus {
  border-color: var(--primary);
}

.color-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.5rem 0;
}

.palette-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s;
}

.palette-btn:hover {
  transform: scale(1.1);
}

.palette-btn.selected {
  border-color: var(--text-main);
  transform: scale(1.1);
  box-shadow: 0 0 0 2px var(--card-bg), 0 0 0 4px var(--text-main);
}

.primary-btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s;
}

.primary-btn:hover {
  background: #4338ca;
}

.subject-list-container h4 {
  font-size: 1rem;
  color: var(--text-main);
  margin-bottom: 1rem;
}

.subject-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.subject-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: var(--bg-app);
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.subject-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.subject-color-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: inline-block;
  border: 1px solid rgba(0,0,0,0.1);
}

.subject-name {
  font-weight: 500;
}

.delete-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s, color 0.2s;
}

.delete-btn:hover {
  background: #fee2e2;
  color: #ef4444;
}

.empty-list {
  color: var(--text-muted);
  text-align: center;
  padding: 1rem;
  font-size: 0.9rem;
}

/* Weekly Timetable */
.weekly-main {
  display: flex;
  flex-direction: column;
}
.weekly-timeline-box {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  background: var(--card-bg);
}
.weekly-header-row {
  display: grid;
  grid-template-columns: 40px repeat(7, 1fr);
  text-align: center;
  background: var(--bg-app);
  border-bottom: 1px solid var(--border-color);
  padding: 8px 0;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
}
.weekly-grid-body {
  display: grid;
  grid-template-columns: 40px repeat(7, 1fr);
}
.weekly-time-col {
  display: flex;
  flex-direction: column;
  background: var(--bg-app);
  border-right: 1px solid var(--border-color);
}
.weekly-hour-label {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  border-bottom: 1px solid var(--border-color);
}
.weekly-day-col {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-color);
}
.weekly-day-col:last-child {
  border-right: none;
}
.weekly-hour-cell {
  height: 60px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
}
.weekly-min-block {
  flex: 1;
  border-bottom: 1px dashed var(--bg-app);
  cursor: pointer;
  transition: background 0.2s;
}
.weekly-min-block:last-child {
  border-bottom: none;
}
.weekly-min-block:hover {
  background-color: var(--primary-soft);
}

/* Color Popup & Dragging */
.color-popup {
  position: fixed;
  background: white;
  border-radius: 8px;
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
  padding: 10px;
  display: flex;
  flex-wrap: wrap;
  max-width: 200px;
  gap: 8px;
  z-index: 1000;
  border: 1px solid var(--border-color);
  transform: translate(-50%, 10px);
}
.popup-color-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.1s;
}
.popup-color-btn:hover {
  transform: scale(1.1);
}
.popup-clear-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: #f1f5f9;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}
.dragging-selected {
  outline: 2px dashed var(--text-main) !important;
  outline-offset: -2px;
}

