/* ==========================================================================
   DESIGN SYSTEM & VARIABLES
   ========================================================================== */

:root {
  /* Font Family */
  --font-sans: 'Outfit', 'Noto Sans JP', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  
  /* Transition Speeds */
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  
  /* Borders & Shadows */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
}

/* DARK MODE VARIABLES */
[data-theme="dark"] {
  --bg-gradient: linear-gradient(135deg, #090714 0%, #110e24 40%, #1d1733 100%);
  --sidebar-bg: rgba(13, 10, 24, 0.93);
  --panel-bg: rgba(22, 18, 38, 0.9);
  --card-bg: rgba(255, 255, 255, 0.05);
  --card-bg-hover: rgba(255, 255, 255, 0.09);
  --border-color: rgba(255, 255, 255, 0.12);
  --border-color-focus: rgba(139, 92, 246, 0.5);
  
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  --accent: #8b5cf6;
  --accent-light: rgba(139, 92, 246, 0.15);
  --accent-hover: #7c3aed;
  --success: #10b981;
  --success-light: rgba(16, 185, 129, 0.15);
  --danger: #ef4444;
  --danger-light: rgba(239, 68, 68, 0.15);
  --warning: #f59e0b;
  --warning-light: rgba(245, 158, 11, 0.15);
  
  --glass-blur: blur(20px);
  --glass-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.4);
  --cell-bg-empty: rgba(255, 255, 255, 0.04);
  --cell-border-empty: dashed rgba(255, 255, 255, 0.18);
}

/* LIGHT MODE VARIABLES */
[data-theme="light"] {
  --bg-gradient: linear-gradient(135deg, #f5f3ff 0%, #fef2f2 50%, #eff6ff 100%);
  --sidebar-bg: rgba(255, 255, 255, 0.5);
  --panel-bg: rgba(255, 255, 255, 0.5);
  --card-bg: rgba(255, 255, 255, 0.7);
  --card-bg-hover: rgba(255, 255, 255, 0.9);
  --border-color: rgba(0, 0, 0, 0.08);
  --border-color-focus: rgba(139, 92, 246, 0.4);
  
  --text-primary: #1f2937;
  --text-secondary: #4b5563;
  --text-muted: #9ca3af;
  
  --accent: #6d28d9;
  --accent-light: rgba(109, 40, 217, 0.08);
  --accent-hover: #5b21b6;
  --success: #059669;
  --success-light: rgba(5, 150, 105, 0.08);
  --danger: #dc2626;
  --danger-light: rgba(220, 38, 38, 0.08);
  --warning: #d97706;
  --warning-light: rgba(217, 119, 6, 0.08);
  
  --glass-blur: blur(14px);
  --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.05);
  --cell-bg-empty: rgba(0, 0, 0, 0.015);
  --cell-border-empty: dashed rgba(0, 0, 0, 0.08);
}

/* ==========================================================================
   RESET & BASE STYLES
   ========================================================================== */

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

body {
  font-family: var(--font-sans);
  background: var(--bg-gradient);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
  transition: color var(--transition-normal);
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: var(--radius-sm);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ==========================================================================
   LAYOUT STRUCTURE
   ========================================================================== */

.app-container {
  display: grid;
  grid-template-columns: 320px 1fr 340px;
  min-height: 100vh;
  width: 100%;
}

/* Sidebars and Panels */
.sidebar, .right-panel {
  background: var(--sidebar-bg);
  backdrop-filter: var(--glass-blur);
  border-right: 1px solid var(--border-color);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  overflow-y: auto;
  max-height: 100vh;
  box-shadow: var(--glass-shadow);
  z-index: 10;
}

.right-panel {
  background: var(--panel-bg);
  border-right: none;
  border-left: 1px solid var(--border-color);
}

.main-content {
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
  max-height: 100vh;
}

/* ==========================================================================
   SIDEBAR & PANEL COMPONENTS
   ========================================================================== */

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 28px;
  height: 28px;
  color: var(--accent);
}

.logo h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

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

.section-title {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title svg {
  width: 16px;
  height: 16px;
  color: var(--accent);
}

.section-desc {
  font-size: 12px;
  color: var(--text-secondary);
}

/* Inputs & Form Elements */
.form-input {
  width: 100%;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  transition: all var(--transition-fast);
}

[data-theme="light"] .form-input {
  background: rgba(255, 255, 255, 0.8);
}

.form-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2), 0 0 8px rgba(139, 92, 246, 0.3);
  background: rgba(0, 0, 0, 0.3);
}

[data-theme="light"] .form-input:focus {
  background: #fff;
  box-shadow: 0 0 0 3px rgba(109, 40, 217, 0.15), 0 0 8px rgba(109, 40, 217, 0.2);
}

.form-group-row {
  display: flex;
  gap: 12px;
}

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

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

/* Buttons */
.icon-btn {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.icon-btn:hover {
  background: var(--card-bg-hover);
  border-color: var(--text-secondary);
}

.icon-btn:active {
  transform: scale(0.95);
}

.icon-btn.small {
  width: 30px;
  height: 30px;
}

.icon-btn svg {
  width: 16px;
  height: 16px;
}

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

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

.primary-btn, .secondary-btn, .action-btn, .success-btn, .danger-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-sans);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  width: auto;
}

.primary-btn {
  background: var(--accent);
  color: #fff;
  border: none;
}
.primary-btn:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.secondary-btn {
  background: var(--card-bg);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}
.secondary-btn:hover {
  background: var(--card-bg-hover);
}

.success-btn {
  background: var(--success);
  color: #fff;
  border: none;
}
.success-btn:hover {
  background: #059669;
}

.danger-btn {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid var(--danger);
}
.danger-btn:hover {
  background: var(--danger);
  color: #fff;
}

.text-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: color var(--transition-fast);
  width: fit-content;
}

.text-btn:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.text-btn.danger {
  color: var(--danger);
}
.text-btn.danger:hover {
  color: #b91c1c;
}

.full-width {
  width: 100%;
}

/* Theme Toggle specificity */
#theme-toggle-btn .sun-icon {
  display: none;
}
#theme-toggle-btn .moon-icon {
  display: block;
}
[data-theme="light"] #theme-toggle-btn .sun-icon {
  display: block;
}
[data-theme="light"] #theme-toggle-btn .moon-icon {
  display: none;
}

/* Timetable Selection */
.timetable-select-wrapper {
  display: flex;
  gap: 8px;
  align-items: center;
}

.timetable-actions {
  display: flex;
  gap: 4px;
}

/* Friend Overlay Custom styles */
.highlight-section {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.05) 0%, rgba(244, 63, 94, 0.05) 100%);
  border: 1px solid rgba(139, 92, 246, 0.2);
  border-radius: var(--radius-md);
  padding: 16px;
}

.overlay-input-group {
  display: flex;
  gap: 6px;
}

.overlay-input-group input {
  flex: 1;
}

.overlay-status {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--accent-light);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  font-size: 12px;
  animation: pulse 2s infinite ease-in-out;
}

.overlay-status svg {
  width: 14px;
  height: 14px;
  vertical-align: middle;
}

.hidden {
  display: none !important;
}

/* Action Grids */
.grid-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.action-btn {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 10px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.action-btn:hover {
  background: var(--card-bg-hover);
  border-color: var(--accent);
}

.action-btn svg {
  width: 14px;
  height: 14px;
  color: var(--accent);
}

.action-btn-sub {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  padding: 8px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 11px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.action-btn-sub:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.label-btn {
  display: inline-flex;
}

/* ==========================================================================
   TIMETABLE GRID AREA
   ========================================================================== */

.timetable-card {
  background: var(--card-bg);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--glass-shadow);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  flex: 1;
}

.timetable-header-block {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 16px;
}

.timetable-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

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

/* Scroll wrapper to prevent overflow on mobile */
.timetable-scroll-container {
  overflow-x: auto;
  width: 100%;
}

.timetable-grid {
  display: grid;
  width: 100%;
  min-width: 700px;
  gap: 8px;
}

/* Header & Time Column styles */
.grid-header-cell {
  padding: 12px 6px;
  font-weight: 700;
  text-align: center;
  font-size: 13px;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--border-color);
  color: var(--text-secondary);
}

.grid-time-cell {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: var(--radius-sm);
  padding: 8px;
  border: 1px solid var(--border-color);
}

[data-theme="light"] .grid-time-cell {
  background: rgba(0, 0, 0, 0.03);
}

.time-num {
  font-size: 16px;
  font-weight: 800;
  color: var(--accent);
}

.time-range {
  font-size: 9px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Empty Cell Styling */
.grid-cell-empty {
  background: var(--cell-bg-empty);
  border: var(--cell-border-empty);
  border-radius: var(--radius-sm);
  min-height: 96px;
  cursor: pointer;
  transition: all var(--transition-normal);
  display: flex;
  align-items: center;
  justify-content: center;
}

.grid-cell-empty::before {
  content: "+";
  font-size: 24px;
  font-weight: 300;
  color: var(--accent);
  opacity: 0;
  transform: scale(0.7);
  transition: all var(--transition-normal);
}

.grid-cell-empty:hover {
  background: rgba(139, 92, 246, 0.03);
  border-color: var(--accent);
  border-style: solid;
  transform: scale(0.99);
}

.grid-cell-empty:hover::before {
  opacity: 1;
  transform: scale(1.1);
}

/* Active Class Card */
.grid-cell-filled {
  background: var(--card-color, var(--accent));
  color: var(--text-color, #fff);
  border-radius: var(--radius-sm);
  padding: 10px;
  min-height: 96px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transition: all var(--transition-normal);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  user-select: none;
}

.grid-cell-filled::before {
  content: '';
  position: absolute;
  top: 0; left: -150%;
  width: 60%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.25), transparent);
  transform: skewX(-20deg);
  transition: none;
  pointer-events: none;
}

.grid-cell-filled:hover::before {
  left: 150%;
  transition: left 0.8s cubic-bezier(0.1, 0.8, 0.3, 1);
}

.grid-cell-filled:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.25), inset 0 1px 1px rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.3);
}

.grid-cell-filled:active {
  transform: translateY(0) scale(0.99);
}

.grid-cell-filled.selected {
  outline: 2px solid #fff;
  outline-offset: 2px;
  box-shadow: 0 0 24px var(--card-color, var(--accent)), 0 0 4px #fff;
  transform: translateY(-4px) scale(1.02);
}

.card-top {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.class-title {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-all;
}

.class-room, .class-teacher {
  font-size: 10px;
  opacity: 0.85;
  display: flex;
  align-items: center;
  gap: 4px;
}

.class-room svg, .class-teacher svg {
  width: 10px;
  height: 10px;
  flex-shrink: 0;
}

.card-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
}

.card-badge {
  font-size: 8px;
  background: rgba(255, 255, 255, 0.25);
  color: inherit;
  padding: 1px 5px;
  border-radius: 4px;
  font-weight: 600;
  text-transform: uppercase;
}

[data-theme="light"] .grid-cell-filled {
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

/* Dragging indicators */
.grid-cell-empty.drag-over {
  border: 2px dashed var(--accent);
  background: var(--accent-light);
}

.grid-cell-filled.dragging {
  opacity: 0.4;
  transform: scale(0.95);
}

/* ==========================================================================
   CREDIT TRACKER STYLING
   ========================================================================== */

.panel-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.credit-dashboard {
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

[data-theme="light"] .credit-dashboard {
  background: rgba(255, 255, 255, 0.4);
}

.credit-total-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 16px;
}

.credit-circular-progress {
  position: relative;
  width: 80px;
  height: 80px;
}

.circular-chart {
  display: block;
  max-width: 100%;
  max-height: 100%;
}

.circle-bg {
  fill: none;
  stroke: var(--border-color);
  stroke-width: 2.8;
}

.circle {
  fill: none;
  stroke-width: 2.8;
  stroke-linecap: round;
  stroke: url(#credit-chart-gradient);
  transition: stroke-dasharray 0.6s ease;
  filter: drop-shadow(0 0 4px rgba(139, 92, 246, 0.4));
}

.percentage-container {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.percentage-val {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-primary);
}

.percentage-unit {
  font-size: 8px;
  color: var(--text-secondary);
}

.credit-info-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.credit-goal-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

.credit-goal-status {
  font-size: 11px;
  color: var(--text-secondary);
}

/* Category stats list */
.credit-categories-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.category-stat-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cat-info {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
}

.cat-name {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
}

.cat-name svg {
  width: 14px;
  height: 14px;
}

.cat-value {
  color: var(--text-primary);
}

.cat-bar {
  height: 8px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.03);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5);
}

[data-theme="light"] .cat-bar {
  background: rgba(0, 0, 0, 0.08);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.15);
}

.cat-progress {
  height: 100%;
  width: 0%;
  border-radius: 4px;
  transition: width 0.6s cubic-bezier(0.1, 0.8, 0.3, 1);
  box-shadow: 0 0 8px var(--bar-glow-color, rgba(139, 92, 246, 0.4));
}

/* Custom progress colors for categories */
[data-cat="special"] .cat-progress {
  background: linear-gradient(90deg, #3b82f6, #60a5fa);
  --bar-glow-color: rgba(59, 130, 246, 0.5);
}
[data-cat="special"] svg { color: #3b82f6; }

[data-cat="general"] .cat-progress {
  background: linear-gradient(90deg, #10b981, #34d399);
  --bar-glow-color: rgba(16, 185, 129, 0.5);
}
[data-cat="general"] svg { color: #10b981; }

[data-cat="seminar"] .cat-progress {
  background: linear-gradient(90deg, #8b5cf6, #a78bfa);
  --bar-glow-color: rgba(139, 92, 246, 0.5);
}
[data-cat="seminar"] svg { color: #8b5cf6; }

[data-cat="other"] .cat-progress {
  background: linear-gradient(90deg, #6b7280, #9ca3af);
  --bar-glow-color: rgba(107, 114, 128, 0.4);
}
[data-cat="other"] svg { color: #6b7280; }

/* Memo Box styling */
.memo-container {
  width: 100%;
}

.memo-textarea {
  width: 100%;
  min-height: 140px;
  resize: vertical;
  font-family: var(--font-sans);
  line-height: 1.5;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 12px;
  transition: all var(--transition-fast);
}

[data-theme="light"] .memo-textarea {
  background: rgba(255, 255, 255, 0.8);
}

/* ==========================================================================
   TASK MANAGER STYLING
   ========================================================================== */

.task-manager {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.add-task-form {
  background: rgba(0, 0, 0, 0.1);
  border: 1px solid var(--border-color);
  padding: 10px;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

[data-theme="light"] .add-task-form {
  background: rgba(255, 255, 255, 0.3);
}

.form-input.small {
  padding: 6px 10px;
  font-size: 12px;
}

.task-form-row {
  display: flex;
  gap: 6px;
}

.task-form-row select {
  flex: 1;
}

.task-list-container {
  max-height: 250px;
  overflow-y: auto;
}

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

.task-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  padding: 10px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

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

.task-checkbox {
  margin-top: 4px;
  cursor: pointer;
  accent-color: var(--accent);
}

.task-details {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.task-title {
  font-size: 12px;
  font-weight: 600;
  word-break: break-all;
}

.task-tag {
  font-size: 9px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.task-tag.has-subject {
  color: var(--accent);
  font-weight: 500;
}

.task-item.completed {
  opacity: 0.55;
}

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

.delete-task-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.delete-task-btn:hover {
  color: var(--danger);
  background: var(--danger-light);
}

.delete-task-btn svg {
  width: 12px;
  height: 12px;
}



/* ==========================================================================
   OVERLAY MODE DISPLAY HIGHLIGHTS
   ========================================================================== */

.matching-banner {
  background: linear-gradient(90deg, #f59e0b, #8b5cf6);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 12px;
  display: flex;
  align-items: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  animation: slideDown 0.3s ease-out;
}

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

/* Multi-person matching Cell styles */
.grid-cell-matching-multi {
  position: relative;
  background: rgba(0, 0, 0, 0.1);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  min-height: 96px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px;
  justify-content: flex-start;
  overflow: hidden;
}

[data-theme="light"] .grid-cell-matching-multi {
  background: rgba(255, 255, 255, 0.3);
}

.mini-class-card {
  border-radius: 4px;
  padding: 4px 6px;
  font-size: 9px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
  border-left: 3px solid var(--accent);
  transition: transform var(--transition-fast) ease;
}

.mini-class-card:hover {
  transform: scale(1.02);
}

.mini-class-card.mine {
  background: var(--card-color, var(--accent));
  color: var(--text-color, #fff);
  border-left-color: var(--danger);
}

.mini-class-card.friend {
  background: var(--card-color, #7c3aed);
  color: var(--text-color, #fff);
  border-left-color: #f43f5e;
}

.mini-card-header {
  display: flex;
  justify-content: space-between;
  font-size: 7px;
  font-weight: 700;
  opacity: 0.8;
}

.mini-card-subject {
  font-weight: 700;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cell-free-list {
  font-size: 8px;
  color: var(--text-secondary);
  text-align: center;
  width: 100%;
  padding-top: 2px;
  border-top: 1px dashed var(--border-color);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: auto; /* Push to bottom of cell */
}

/* Glowing gold when ALL are free */
.grid-cell-matching-free {
  background: rgba(245, 158, 11, 0.18);
  border: 2px dashed #fbbf24;
  border-radius: var(--radius-sm);
  min-height: 96px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: #fbbf24;
  text-align: center;
  animation: goldGlow 3s infinite ease-in-out;
}

.grid-cell-matching-free::before {
  content: "全員空き！";
  font-size: 11px;
  font-weight: 700;
}

.grid-cell-matching-free::after {
  content: "全員スケジュールフリー";
  font-size: 8px;
  opacity: 0.8;
}

/* Sidebar Friends Roster styling */
.friends-list-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
  padding-top: 12px;
  border-top: 1px dashed var(--border-color);
}

.friends-list-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
}

.friends-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 150px;
  overflow-y: auto;
  padding-right: 4px;
}

.friend-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.2);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  border: 1px solid var(--border-color);
}

[data-theme="light"] .friend-list-item {
  background: rgba(255, 255, 255, 0.8);
}

.friend-item-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.friend-item-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
  color: var(--text-primary);
}

.friend-checkbox {
  cursor: pointer;
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
}

.friend-remove-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.friend-remove-btn:hover {
  color: var(--danger);
}

.friend-remove-btn svg {
  width: 12px;
  height: 12px;
}

@keyframes glow {
  from { box-shadow: 0 0 4px rgba(245, 158, 11, 0.2); }
  to { box-shadow: 0 0 16px rgba(245, 158, 11, 0.6); }
}

@keyframes goldGlow {
  0% {
    box-shadow: 0 0 4px rgba(245, 158, 11, 0.25), inset 0 0 4px rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.5);
  }
  50% {
    box-shadow: 0 0 24px rgba(245, 158, 11, 0.65), inset 0 0 12px rgba(245, 158, 11, 0.25);
    border-color: rgba(245, 158, 11, 1);
    transform: scale(0.99);
  }
  100% {
    box-shadow: 0 0 4px rgba(245, 158, 11, 0.25), inset 0 0 4px rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.5);
  }
}

/* ==========================================================================
   MODAL OVERLAY STYLE
   ========================================================================== */

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(10px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--sidebar-bg);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-lg);
  width: 500px;
  max-width: 90%;
  padding: 24px;
  box-shadow: var(--glass-shadow);
  transform: scale(0.9) translateY(20px);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow-y: auto;
  max-height: 90vh;
}

.modal.active .modal-content {
  transform: scale(1) translateY(0);
}

.glass-effect {
  backdrop-filter: var(--glass-blur);
}

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

.modal-header h3 {
  font-size: 18px;
  font-weight: 700;
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Color dot selectors */
.color-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.color-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.color-dot.active {
  border-color: var(--text-primary);
  transform: scale(1.15);
  box-shadow: 0 0 8px var(--text-secondary);
}

.modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border-color);
  padding-top: 16px;
  margin-top: 10px;
}

.footer-right-buttons {
  display: flex;
  gap: 10px;
}

.time-inputs-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 350px;
  overflow-y: auto;
  padding-right: 4px;
}

.time-row {
  display: grid;
  grid-template-columns: 50px 1fr 1fr;
  gap: 10px;
  align-items: center;
}

.time-row-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
}

/* ==========================================================================
   ANIMATIONS & KEYFRAMES
   ========================================================================== */

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.4); }
  70% { box-shadow: 0 0 0 8px rgba(139, 92, 246, 0); }
  100% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0); }
}

/* ==========================================================================
   PRINT MEDIA RULES
   ========================================================================== */

@media print {
  body {
    background: #fff !important;
    color: #000 !important;
  }
  
  .app-container {
    display: block !important;
  }
  
  .sidebar, .right-panel, #matching-banner, .modal {
    display: none !important;
  }
  
  .main-content {
    padding: 0 !important;
    max-height: none !important;
    overflow: visible !important;
  }
  
  .timetable-card {
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
    padding: 0 !important;
  }
  
  .timetable-grid {
    min-width: 100% !important;
  }
  
  .grid-time-cell {
    background: #f3f4f6 !important;
    border: 1px solid #ccc !important;
    color: #000 !important;
  }
  
  .time-num, .grid-header-cell {
    color: #000 !important;
  }
  
  .grid-cell-filled {
    border: 1px solid #aaa !important;
    box-shadow: none !important;
    background: var(--card-color) !important;
    color: #000 !important; /* Force readable text */
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  
  .card-badge {
    border: 1px solid #ccc !important;
    background: #fff !important;
    color: #000 !important;
  }
}

/* ==========================================================================
   RESPONSIVE MEDIA QUERIES (TABLET & MOBILE)
   ========================================================================== */

@media (max-width: 1200px) {
  .app-container {
    grid-template-columns: 300px 1fr;
  }
  
  .right-panel {
    grid-column: 1 / -1;
    border-left: none;
    border-top: 1px solid var(--border-color);
    max-height: none;
    background: var(--sidebar-bg);
  }
}

@media (max-width: 850px) {
  .app-container {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 100vh;
  }
  
  .main-content {
    order: 1; /* Timetable Grid at the top of the flow on mobile! */
    max-height: none;
    overflow: visible;
    padding: 16px;
  }
  
  .right-panel {
    order: 2; /* Tasks and Memo second */
    border-left: none;
    border-top: 1px solid var(--border-color);
    max-height: none;
    overflow: visible;
    padding: 24px;
    background: var(--sidebar-bg);
  }
  
  .sidebar {
    order: 3; /* Settings third */
    max-height: none;
    border-right: none;
    border-top: 1px solid var(--border-color);
    overflow: visible;
    padding: 24px;
  }
  
  .timetable-card {
    padding: 16px;
  }
  
  .timetable-title {
    font-size: 20px;
  }
}

/* Mobile Day Selector Tabs */
.mobile-day-tabs {
  display: none;
}

@media (max-width: 650px) {
  .mobile-day-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 14px;
    width: 100%;
    justify-content: space-between;
  }
  
  .day-tab {
    flex: 1;
    text-align: center;
    padding: 8px 4px;
    font-size: 11px;
    font-weight: 700;
    font-family: var(--font-sans);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
  }
  
  .day-tab:hover {
    background: var(--card-bg-hover);
    color: var(--text-primary);
  }
  
  .day-tab.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    box-shadow: 0 4px 12px var(--accent-light);
  }
  
  .timetable-grid {
    min-width: 0 !important; /* Allow dynamic shrinking on small screens */
  }
}
