:root {
  --primary: #1e90ff;
  --secondary: #333;
  --background: #f4f4f4;
  --error: #ff4444;
  --success: #28a745;
  --card-bg: #fff;
  --card-border: #e0e0e0;
  --text: #333;
  --shadow: rgba(0,0,0,0.1);
  --transition: all 0.3s ease;
}

body.dark-mode {
  --primary: #66b3ff;
  --secondary: #ddd;
  --background: #1a1a1a;
  --error: #ff6666;
  --success: #4caf50;
  --card-bg: #2a2a2a;
  --card-border: #444;
  --text: #ddd;
  --shadow: rgba(255,255,255,0.1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Segoe UI', Arial, sans-serif;
  margin: 0;
  padding: 60px 20px 20px;
  background: var(--background);
  color: var(--text);
  line-height: 1.6;
  transition: var(--transition);
}

h1, h2 {
  text-align: center;
  margin: 0 0 15px;
}

h1 {
  color: var(--primary);
  font-size: 2.5em;
  margin-bottom: 30px;
}

.top-menu {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--card-bg);
  padding: 10px 20px;
  box-shadow: 0 2px 8px var(--shadow);
  z-index: 1000;
  display: flex;
  justify-content: flex-start;
  gap: 15px;
}

.top-menu button {
  background: var(--primary);
  padding: 8px 15px;
  border: none;
  border-radius: 5px;
  color: white;
  cursor: pointer;
  transition: background 0.3s;
}

.top-menu button:hover {
  background: #187bcd;
}

.top-menu button.dark-mode-toggle {
  background: var(--secondary);
}

.top-menu button.dark-mode-toggle:hover {
  background: #555;
}

.container {
  max-width: 900px;
  margin: 20px auto;
  background: var(--card-bg);
  padding: 20px;
  border-radius: 10px;
  box-shadow: 0 4px 8px var(--shadow);
  transition: background 0.3s;
}

.warning {
  background: #ffeb3b;
  color: #333;
  padding: 10px;
  border-radius: 5px;
  margin-bottom: 15px;
  text-align: center;
  font-weight: bold;
}

#file-input-wrapper {
  position: relative;
  display: inline-block;
  margin-right: 10px;
}

#file {
  opacity: 0;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

#file-label {
  background: var(--primary);
  padding: 8px 15px;
  border: none;
  border-radius: 5px;
  color: white;
  cursor: pointer;
  transition: background 0.3s;
  display: inline-block;
}

#file-label:hover {
  background: #187bcd;
}

#file-name {
  margin-left: 10px;
  font-size: 0.9em;
  color: var(--text);
  vertical-align: middle;
}

.form-row {
  display: flex;
  gap: 20px;
  margin-bottom: 15px;
  justify-content: center;
  flex-wrap: wrap;
}

.form-row.file-input-row {
  justify-content: flex-start;
}

.form-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.form-item label {
  font-weight: bold;
  min-width: 80px;
  text-align: right;
}

.form-item input[type="number"],
.form-item input[type="text"] {
  padding: 6px;
  border: 1px solid var(--card-border);
  border-radius: 5px;
  background: var(--card-bg);
  color: var(--text);
  transition: border 0.3s, background 0.3s, color 0.3s;
  width: 70px;
  text-align: center;
}

input.valid {
  border-color: var(--success);
}

input.invalid {
  border-color: var(--error);
}

button {
  background: var(--primary);
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.3s, transform 0.1s;
}

button:hover {
  background: #187bcd;
}

button:active {
  transform: scale(0.98);
}

button:disabled {
  background: #aaa;
  cursor: not-allowed;
}

.analyze-section {
  text-align: center;
}

.progress-bar {
  width: 0%;
  height: 5px;
  background: var(--primary);
  border-radius: 5px;
  transition: width 0.3s ease;
  margin-top: 10px;
}

.notification {
  position: fixed;
  top: 60px;
  right: 20px;
  padding: 15px 25px;
  border-radius: 5px;
  color: white;
  font-weight: bold;
  box-shadow: 0 2px 4px var(--shadow);
  z-index: 2000;
  animation: slideIn 0.3s ease-out, fadeOut 0.3s ease-out 4.7s;
}

.notification.error {
  background: var(--error);
}

.notification.success {
  background: var(--success);
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

.sort-controls {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  justify-content: center;
}

.loop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.loops-container {
  margin-top: 20px;
}

.loop-item {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 2px 8px var(--shadow);
  transition: transform 0.2s ease, background 0.3s, border 0.3s;
  cursor: grab;
}

.loop-item:hover {
  transform: translateY(-4px);
}

.loop-details h3 {
  margin-top: 0;
  font-size: 1.2em;
  color: var(--primary);
}

.loop-details p {
  margin: 6px 0;
  font-size: 0.9em;
}

.button-group {
  margin-top: 12px;
  display: flex;
  gap: 10px;
}

.button-group button {
  flex: 1;
}

.waveform {
  width: 100%;
  height: 100px;
  background: #f0f0f0;
  border: 1px solid var(--card-border);
  border-radius: 4px;
  margin-bottom: 10px;
  transition: background 0.3s, border 0.3s;
}

body.dark-mode .waveform {
  background: #333;
}

.panel {
  position: fixed;
  top: 0;
  right: -400px;
  width: 400px;
  height: 100%;
  background: var(--card-bg);
  box-shadow: -2px 0 8px var(--shadow);
  padding: 20px;
  transition: right 0.3s ease;
  z-index: 999;
  overflow-y: auto;
}

.panel.open {
  right: 0;
}

.panel h3 {
  margin-top: 0;
}

.basket-item {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--card-border);
}

.basket-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.basket-item-details {
  font-size: 0.8em;
  margin-top: 4px;
  color: var(--secondary);
}

.basket-item button {
  align-self: flex-end;
  background: var(--error);
  padding: 5px 10px;
  margin-top: 5px;
}

.basket-total {
  font-weight: bold;
  text-align: right;
  margin: 20px 0;
}

.clear-btn {
  background: var(--error);
  margin-bottom: 20px;
}

.close-btn {
  background: var(--error);
  margin-top: 20px;
}

.download-btn {
  background: var(--success);
  margin-top: 20px;
  display: none;
  width: 100%;
}

.panel-content {
  display: none;
}

.panel-content.active {
  display: block;
}

.panel ol {
  padding-left: 20px;
}

.panel li {
  margin-bottom: 8px;
}

.panel p {
  margin: 10px 0;
  font-size: 0.9em;
}