:root {
  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --danger-color: #ef4444;
  --danger-hover: #dc2626;
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --border-color: #e2e8f0;
  --border-light: #f1f5f9;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem;
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Header */
.app-header {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
}

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

.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 0.9rem;
  background-color: #f1f5f9;
  color: #334155;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  transition: var(--transition);
  border: 1px solid #e2e8f0;
}

.btn-back:hover {
  background-color: #e2e8f0;
  color: #0f172a;
}

.header-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: white;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.25);
}

.header-titles h1 {
  font-size: 1.25rem;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.02em;
}

.header-titles .subtitle {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn-header {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.85rem;
  background-color: #ffffff;
  color: #334155;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-header:hover {
  background-color: #f8fafc;
  border-color: #cbd5e1;
  color: var(--text-primary);
}

.btn-stop-all {
  background-color: #fee2e2;
  border-color: #fca5a5;
  color: #b91c1c;
}

.btn-stop-all:hover {
  background-color: #fecaca;
  color: #991b1b;
}

.btn-danger {
  color: #dc2626;
}

.btn-danger:hover {
  background-color: #fef2f2;
  border-color: #f87171;
}

/* Master Control Bar */
.master-control-bar {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
}

.master-vol-box {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.master-vol-box label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
}

.vol-icon {
  font-size: 1.15rem;
}

input[type="range"] {
  accent-color: var(--primary-color);
  height: 6px;
  border-radius: 3px;
  cursor: pointer;
}

.master-vol-box input[type="range"] {
  width: 140px;
}

.vol-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--primary-color);
  min-width: 40px;
}

.legend-badge {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  background-color: #f1f5f9;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
}

.legend-badge strong {
  color: #0f172a;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #059669;
  background-color: #ecfdf5;
  padding: 0.35rem 0.75rem;
  border-radius: 9999px;
  border: 1px solid #a7f3d0;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #10b981;
}

/* Layout Grid */
.main-layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 1.25rem;
  align-items: start;
}

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

/* Soundboard Section */
.soundboard-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.section-title-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-light);
}

.section-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.125rem;
  font-weight: 700;
  color: #0f172a;
}

.section-badge {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--primary-color);
  background-color: var(--primary-light);
  padding: 0.25rem 0.6rem;
  border-radius: 9999px;
  border: 1px solid #bfdbfe;
}

.sound-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

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

/* Sound Card */
.sound-card {
  position: relative;
  background: #ffffff;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  transition: var(--transition);
}

.sound-card:hover {
  border-color: #93c5fd;
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.sound-card.playing {
  border-color: #3b82f6;
  background-color: #eff6ff;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25), var(--shadow-md);
}

.card-shortcut {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 24px;
  height: 24px;
  background-color: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #475569;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.sound-card.playing .card-shortcut {
  background-color: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.card-icon {
  font-size: 2.25rem;
  line-height: 1;
  margin-bottom: 0.25rem;
}

.sound-title {
  font-size: 1rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 0.25rem;
}

.sound-desc {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.4;
  min-height: 2.8em;
}

.card-vol-control {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background-color: #f8fafc;
  padding: 0.4rem 0.65rem;
  border-radius: var(--radius-sm);
  border: 1px solid #f1f5f9;
}

.card-vol-control label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.card-vol-control input[type="range"] {
  flex: 1;
}

.sound-vol-txt {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  font-weight: 700;
  color: #334155;
  min-width: 34px;
  text-align: right;
}

.card-actions {
  display: flex;
  gap: 0.5rem;
}

.btn-play-sound {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  padding: 0.65rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
}

.btn-play-sound:hover {
  background: linear-gradient(135deg, #1d4ed8, #1e40af);
  transform: translateY(-1px);
  box-shadow: 0 4px 6px rgba(37, 99, 235, 0.3);
}

.sound-card.playing .btn-play-sound {
  background: linear-gradient(135deg, #10b981, #059669);
  animation: pulse 1s infinite alternate;
}

@keyframes pulse {
  0% { transform: scale(1); }
  100% { transform: scale(1.02); }
}

/* Sidebar Section */
.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.panel-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.panel-header h3 {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 1rem;
  font-weight: 700;
  color: #0f172a;
}

.panel-desc {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-top: 0.35rem;
  margin-bottom: 1rem;
}

/* Timer Chime Card */
.timer-display-box {
  background: linear-gradient(145deg, #0f172a, #1e293b);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
  color: white;
}

.timer-time {
  font-family: 'JetBrains Mono', monospace;
  font-size: 2.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #38bdf8;
  line-height: 1.1;
}

.timer-time.urgent {
  color: #f87171;
  animation: blink 0.75s infinite alternate;
}

@keyframes blink {
  0% { opacity: 1; }
  100% { opacity: 0.6; }
}

.timer-status-badge {
  font-size: 0.75rem;
  font-weight: 600;
  background-color: rgba(255, 255, 255, 0.12);
  padding: 0.2rem 0.65rem;
  border-radius: 9999px;
  margin-top: 0.35rem;
  color: #cbd5e1;
}

.timer-status-badge.active {
  background-color: #059669;
  color: white;
}

.quick-timer-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.85rem;
}

.btn-preset {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
  transition: var(--transition);
}

.btn-preset:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.btn-preset.active {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.custom-timer-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  margin-bottom: 0.85rem;
}

.input-grp {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.input-grp label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.input-grp input {
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.875rem;
  font-weight: 600;
  outline: none;
}

.input-grp input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.timer-sound-select {
  margin-bottom: 1rem;
}

.timer-sound-select label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
}

.timer-sound-select select {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-primary);
  background-color: white;
  outline: none;
}

.timer-sound-select select:focus {
  border-color: var(--primary-color);
}

.timer-controls {
  display: grid;
  grid-template-columns: 1.2fr 1fr 0.9fr;
  gap: 0.4rem;
}

.btn-timer-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.55rem 0.65rem;
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--transition);
}

.btn-timer-start {
  background: #10b981;
  color: white;
}

.btn-timer-start:hover {
  background: #059669;
}

.btn-timer-pause {
  background: #f59e0b;
  color: white;
}

.btn-timer-pause:hover:not(:disabled) {
  background: #d97706;
}

.btn-timer-pause:disabled {
  background: #cbd5e1;
  color: #94a3b8;
  cursor: not-allowed;
}

.btn-timer-reset {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #475569;
}

.btn-timer-reset:hover {
  background: #e2e8f0;
  color: #0f172a;
}

/* Shortcuts Card */
.shortcuts-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.shortcuts-list li {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 0.8125rem;
  color: #334155;
}

.shortcuts-list kbd {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
  color: #1e293b;
  background-color: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
  min-width: 24px;
  text-align: center;
}

/* Footer */
.app-footer {
  text-align: center;
  padding: 1rem 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-light);
  margin-top: auto;
}

/* Modal Overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal-overlay.show {
  display: flex;
}

.modal-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  max-width: 420px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: modalIn 0.2s ease-out;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 0.5rem;
}

.modal-desc {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
}

.btn-modal-cancel {
  flex: 1;
  padding: 0.65rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: #f8fafc;
  color: #475569;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: var(--transition);
}

.btn-modal-cancel:hover {
  background: #f1f5f9;
}

.btn-modal-confirm {
  flex: 1;
  padding: 0.65rem 1rem;
  border-radius: var(--radius-md);
  border: none;
  background: var(--danger-color);
  color: white;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: var(--transition);
}

.btn-modal-confirm:hover {
  background: var(--danger-hover);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1e293b;
  color: white;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
  font-weight: 500;
  display: none;
  align-items: center;
  gap: 0.5rem;
  z-index: 1100;
  transform: translateY(10px);
  opacity: 0;
  transition: var(--transition);
}

.toast.show {
  display: flex;
  transform: translateY(0);
  opacity: 1;
}

.toast.success {
  background: #065f46;
  border-left: 4px solid #10b981;
}

.toast.info {
  background: #1e293b;
  border-left: 4px solid #3b82f6;
}

.toast.warning {
  background: #78350f;
  border-left: 4px solid #f59e0b;
}
