/* ============================================================
   CaYaSound — Ses Düzenleyici
   CaYaDev teması: koyu zemin + kırmızı vurgu + terminal yeşili
   ============================================================ */

:root {
  --bg:        #0b0608;
  --bg-1:      #0f090c;
  --bg-2:      #150c10;
  --bg-3:      #1c1116;
  --surface:   #0d0a0e;
  --panel:     #100a0d;

  --red:       #e51e2b;
  --red-hi:    #ff2e3e;
  --red-deep:  #a5151f;
  --red-glow:  rgba(229, 30, 43, 0.45);

  --green:     #3fb950;
  --green-hi:  #56d364;
  --cyan:      #37c4d4;
  --yellow:    #e5c07b;
  --blue:      #1f6fc4;

  --text:      #ecebef;
  --text-2:    #b9b6c0;
  --muted:     #7d7986;
  --muted-2:   #565360;

  --border:    rgba(255, 255, 255, 0.08);
  --border-2:  rgba(255, 255, 255, 0.14);
  --hair:      rgba(255, 255, 255, 0.05);

  --wave-bg:   #0c0a0d;
  --radius:    10px;
  --radius-sm: 7px;

  --topbar-h:  58px;
  --status-h:  30px;
  --panel-w:   320px;

  --mono: ui-monospace, "Cascadia Code", "JetBrains Mono", "SF Mono", Consolas, monospace;
  --sans: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--sans);
  color: var(--text);
  background:
    radial-gradient(1100px 620px at 12% -8%, rgba(229, 30, 43, 0.16), transparent 60%),
    radial-gradient(900px 700px at 100% 110%, rgba(229, 30, 43, 0.08), transparent 55%),
    var(--bg);
  display: grid;
  grid-template-rows: var(--topbar-h) 1fr var(--status-h);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font-family: inherit; }
::selection { background: var(--red-glow); color: #fff; }

/* İkonlar: varsayılan çizgi (stroke) = currentColor; dolgu için .ico-fill.
   Böylece koyu butonlarda ikonlar açık/beyaz görünür, kaybolmaz. */
.ico { fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.ico-fill { fill: currentColor; stroke: none; }

/* ===================== TOP BAR ===================== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 18px;
  background: linear-gradient(180deg, rgba(255,255,255,0.02), transparent);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 20;
}
.topbar::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--red), transparent);
  opacity: 0.6;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
  white-space: nowrap;
}
.brand-mark { width: 30px; height: 30px; fill: var(--red); filter: drop-shadow(0 0 6px var(--red-glow)); }
.brand-mark rect:nth-child(odd) { fill: var(--red); }
.brand-mark rect:nth-child(even) { fill: #f4f4f6; }
.brand-text { font-size: 19px; font-weight: 700; letter-spacing: -0.02em; }
.brand-text b { color: var(--red); font-weight: 800; }
.brand-tag {
  font-size: 11px;
  color: var(--muted);
  border-left: 1px solid var(--border-2);
  padding-left: 10px;
  margin-left: 2px;
  letter-spacing: 0.02em;
}

.toolbar { display: flex; align-items: center; gap: 8px; }

/* ===================== BUTTONS ===================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 13px;
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .14s, border-color .14s, transform .06s, box-shadow .14s, color .14s;
  white-space: nowrap;
  user-select: none;
}
.btn:hover:not(:disabled) { background: var(--bg-3); border-color: var(--border-2); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn .ico { width: 16px; height: 16px; }

.btn-primary {
  background: linear-gradient(180deg, var(--red-hi), var(--red));
  border-color: var(--red-deep);
  color: #fff;
  box-shadow: 0 1px 0 rgba(255,255,255,.12) inset, 0 6px 18px -8px var(--red-glow);
}
.btn-primary:hover:not(:disabled) { background: linear-gradient(180deg, #ff4351, var(--red-hi)); }

.btn-green {
  background: linear-gradient(180deg, var(--green-hi), var(--green));
  border-color: #2c8a3b;
  color: #06210c;
}
.btn-green:hover:not(:disabled) { filter: brightness(1.06); }

.btn-lg { height: 42px; padding: 0 22px; font-size: 14px; border-radius: 9px; }

.btn-lang { padding: 0 11px; gap: 6px; }
.btn-lang #langLabel { font-family: var(--mono); font-size: 12px; font-weight: 700; letter-spacing: 0.04em; min-width: 18px; text-align: center; }
.btn-lang .ico { width: 16px; height: 16px; }

.divider { width: 1px; height: 22px; background: var(--border); margin: 0 3px; }

.select {
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.select:focus { outline: none; border-color: var(--red); }

/* ===================== WORKSPACE ===================== */
.workspace {
  display: grid;
  grid-template-columns: 1fr var(--panel-w);
  min-height: 0;
  overflow: hidden;
}

.editor {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: 14px 14px 8px;
  gap: 10px;
}

/* ===================== TRANSPORT ===================== */
.transport {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 8px 12px;
  background: linear-gradient(180deg, var(--bg-1), var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.transport-left, .transport-right { display: flex; align-items: center; gap: 8px; }

.tbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border-2);
  border-radius: 8px;
  background: var(--bg-2);
  color: var(--text);
  cursor: pointer;
  transition: background .14s, border-color .14s, color .14s, transform .06s;
}
.tbtn:hover:not(:disabled) { background: var(--bg-3); color: #fff; }
.tbtn:active:not(:disabled) { transform: translateY(1px); }
.tbtn:disabled { opacity: .38; cursor: not-allowed; }
.tbtn .ico { width: 18px; height: 18px; }
.tbtn-wide { width: auto; padding: 0 12px; font-size: 12px; font-weight: 700; }

.tbtn-play {
  background: linear-gradient(180deg, var(--red-hi), var(--red));
  border-color: var(--red-deep);
  color: #fff;
  width: 42px; height: 42px;
  box-shadow: 0 6px 18px -8px var(--red-glow);
}
.tbtn-play:hover:not(:disabled) { filter: brightness(1.08); }
.ico-pause { display: none; }
body.is-playing .ico-play  { display: none; }
body.is-playing .ico-pause { display: block; }

.time-readout {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-left: 10px;
  font-family: var(--mono);
  font-size: 14px;
  letter-spacing: 0.02em;
}
#timeCur { color: var(--green-hi); font-weight: 600; }
#timeDur { color: var(--muted); font-size: 12.5px; }
.time-sep { color: var(--muted-2); }

.vol { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.vol .ico { width: 18px; height: 18px; }

/* Range inputs */
.range { -webkit-appearance: none; appearance: none; height: 5px; border-radius: 4px;
  background: linear-gradient(90deg, var(--red-deep), var(--red)); cursor: pointer; width: 100%; }
.range.range-slim { width: 108px; }
.range::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 15px; height: 15px;
  border-radius: 50%; background: #fff; border: 2px solid var(--red); box-shadow: 0 0 8px var(--red-glow); cursor: pointer; }
.range::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #fff;
  border: 2px solid var(--red); cursor: pointer; }
.range:disabled { filter: grayscale(.7); opacity: .5; }

.mono-sm { font-family: var(--mono); font-size: 11.5px; color: var(--text-2); }

/* ===================== WAVEFORM ===================== */
.wave-wrap {
  position: relative;
  flex: 1;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  background: var(--wave-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.wave-scroll { position: relative; flex: 1; display: flex; flex-direction: column; min-height: 0; }

.ruler { display: block; width: 100%; height: 26px; flex: 0 0 26px;
  border-bottom: 1px solid var(--border); background: var(--bg-1); }

.channels { position: relative; flex: 1; display: flex; flex-direction: column; min-height: 0; }
.channel { position: relative; flex: 1; min-height: 0; border-bottom: 1px solid var(--hair); }
.channel:last-of-type { border-bottom: 0; }
.wave { display: block; width: 100%; height: 100%; }

/* Kanal başlığı = tıklanabilir kilit düğmesi (solo/aç-kapa) */
.ch-label {
  position: absolute; top: 7px; left: 9px; z-index: 4;
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--mono); font-size: 10.5px; font-weight: 700;
  letter-spacing: 0.08em; color: var(--text-2);
  background: rgba(0,0,0,0.5); border: 1px solid var(--border);
  padding: 3px 8px; border-radius: 6px; cursor: pointer;
  transition: color .14s, border-color .14s, background .14s, box-shadow .14s;
}
.ch-label:hover:not(:disabled) { color: #fff; border-color: var(--border-2); background: rgba(0,0,0,0.62); }
.ch-label:disabled { cursor: default; }
.ch-label .ch-lock { width: 12px; height: 12px; flex: 0 0 auto;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
  opacity: .4; transition: opacity .14s, stroke .14s; }

/* Solo modda ETKİN kanal başlığı vurgulanır (camgöbeği) */
.channel.ch-active .ch-label {
  color: var(--cyan); border-color: rgba(55,196,212,.55);
  box-shadow: 0 0 0 1px rgba(55,196,212,.25), 0 0 12px -4px rgba(55,196,212,.5);
}
.channel.ch-active .ch-label .ch-lock { opacity: 0; } /* açık kanalda kilit gizli */

/* KİLİTLİ kanal: dalga soluk + asma kilit + rozet */
.channel.ch-locked .wave { opacity: .3; filter: grayscale(.5); }
.channel.ch-locked .ch-label { color: var(--yellow); border-color: rgba(229,192,123,.5); background: rgba(229,192,123,.08); }
.channel.ch-locked .ch-label .ch-lock { opacity: 1; stroke: var(--yellow); }
.ch-lock-badge {
  position: absolute; top: 7px; right: 9px; z-index: 4; display: none;
  font-family: var(--mono); font-size: 10px; font-weight: 800; letter-spacing: 0.12em;
  color: #2a1e05; background: linear-gradient(180deg, #f0d18a, var(--yellow));
  border: 1px solid #b9954f; padding: 2px 7px; border-radius: 5px; pointer-events: none;
}
.channel.ch-locked .ch-lock-badge { display: block; }

.overlay { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 2; cursor: text; }

/* ---- Kayan Kazanç tutamacı (seçim üzerinde belirir, dikey sürükle) ---- */
.gain-handle {
  position: absolute; top: 14px; z-index: 5;
  transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 8px;
  height: 30px; padding: 0 12px 0 10px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(28,20,26,.94), rgba(16,10,14,.94));
  border: 1px solid var(--border-2);
  box-shadow: 0 10px 26px -10px rgba(0,0,0,.8), 0 0 0 1px rgba(0,0,0,.3),
              inset 0 1px 0 rgba(255,255,255,.06);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  cursor: ns-resize; user-select: none; touch-action: none;
  color: var(--text-2); white-space: nowrap;
  transition: border-color .14s, box-shadow .14s, transform .05s;
  animation: ghPop .18s ease;
}
.gain-handle[hidden] { display: none; }
.gain-handle:hover,
.gain-handle.dragging {
  border-color: var(--cyan);
  box-shadow: 0 12px 30px -10px rgba(0,0,0,.85), 0 0 0 1px rgba(55,196,212,.35),
              0 0 18px -4px rgba(55,196,212,.45);
}
.gain-handle.dragging { transform: translateX(-50%) scale(1.03); }

.gain-handle .gh-ico { width: 16px; height: 16px; flex: 0 0 auto;
  fill: none; stroke: var(--cyan); stroke-width: 2; stroke-linecap: round; opacity: .9; }

.gain-handle .gh-grip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 50%; flex: 0 0 auto;
  background: radial-gradient(circle at 50% 35%, #2a1e26, #140d12);
  border: 1px solid var(--border-2);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
}
.gain-handle .gh-grip svg { width: 15px; height: 15px; fill: var(--muted); }
.gain-handle:hover .gh-grip svg,
.gain-handle.dragging .gh-grip svg { fill: var(--cyan); }

.gain-handle .gh-val {
  font-family: var(--mono); font-size: 13px; font-weight: 700;
  letter-spacing: .01em; color: var(--cyan); min-width: 58px; text-align: center;
  text-shadow: 0 0 10px rgba(55,196,212,.25);
}
@keyframes ghPop { from { opacity: 0; transform: translateX(-50%) translateY(-5px); } }

/* horizontal scrollbar */
.hbar { height: 12px; background: var(--bg-1); border-top: 1px solid var(--border);
  position: relative; display: none; }
.hbar.on { display: block; }
.hbar-thumb { position: absolute; top: 2px; height: 8px; border-radius: 4px;
  background: var(--border-2); cursor: grab; left: 0; width: 100%; }
.hbar-thumb:hover { background: rgba(255,255,255,.25); }
.hbar-thumb:active { cursor: grabbing; background: var(--red); }

/* Dropzone */
.dropzone {
  position: absolute; inset: 0; z-index: 6;
  display: flex; align-items: center; justify-content: center;
  background: rgba(10, 6, 8, 0.72);
  backdrop-filter: blur(2px);
  transition: background .15s, opacity .15s;
}
.dropzone.hide { opacity: 0; pointer-events: none; }
.dropzone.drag { background: rgba(229, 30, 43, 0.12); }
.dropzone.drag .dz-inner { border-color: var(--red); box-shadow: 0 0 40px -8px var(--red-glow); }
.dz-inner {
  text-align: center; padding: 34px 46px; border-radius: 14px;
  border: 1.5px dashed var(--border-2); background: rgba(255,255,255,0.015);
  transition: border-color .15s, box-shadow .15s;
}
.dz-ico { width: 46px; height: 46px; fill: none; stroke: var(--red); stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round; margin-bottom: 8px; }
.dropzone h2 { margin: 6px 0 4px; font-size: 19px; font-weight: 700; }
.dropzone p { margin: 4px 0; color: var(--muted); font-size: 13px; }
.dz-inner .btn { margin-top: 14px; }
.dz-hint { font-size: 11.5px !important; color: var(--muted-2) !important; margin-top: 14px !important; }

/* Busy */
.busy { position: absolute; inset: 0; z-index: 8; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 14px; background: rgba(10,6,8,.66); backdrop-filter: blur(2px); }
.busy[hidden] { display: none; }
.busy span { font-size: 13px; color: var(--text-2); font-family: var(--mono); }
.spinner { width: 38px; height: 38px; border-radius: 50%; border: 3px solid var(--border-2);
  border-top-color: var(--red); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===================== TOOL PANEL ===================== */
.panel {
  border-left: 1px solid var(--border);
  background: linear-gradient(180deg, var(--panel), var(--bg));
  min-height: 0;
  overflow: hidden;
}
.panel-scroll { height: 100%; overflow-y: auto; padding: 14px; }
.panel-scroll::-webkit-scrollbar { width: 10px; }
.panel-scroll::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
.panel-scroll::-webkit-scrollbar-thumb:hover { background: var(--border-2); background-clip: content-box; }

.tool-group { margin-bottom: 20px; }
.tg-title {
  margin: 0 0 4px; font-size: 12px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text);
  display: flex; align-items: center; gap: 8px;
}
.tg-title::before { content: ""; width: 3px; height: 13px; background: var(--red); border-radius: 2px; box-shadow: 0 0 8px var(--red-glow); }
.tg-hint { margin: 0 0 11px; font-size: 11.5px; color: var(--muted); line-height: 1.4; }

.btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.btn.tool {
  height: 34px; padding: 0 10px; font-size: 12.5px; font-weight: 600;
  justify-content: center; background: var(--bg-1); border-color: var(--border);
}
.btn.tool:hover:not(:disabled) { background: var(--bg-3); border-color: var(--red-deep); color: #fff; }

.fx-row { margin-bottom: 14px; }
.fx-row label { display: flex; justify-content: space-between; align-items: baseline;
  font-size: 12.5px; font-weight: 600; margin-bottom: 7px; color: var(--text-2); }
.fx-row .range { margin-bottom: 9px; }
.fx-apply { width: 100%; }
.fx-note { margin: -4px 0 16px; font-size: 11px; color: var(--muted); }
.fx-gain-note {
  display: flex; align-items: flex-start; gap: 10px;
  margin-top: 4px; padding-top: 14px; border-top: 1px solid var(--border);
}
.fx-gain-note .tg-hint { margin: 0; }
.fx-gain-badge {
  flex: 0 0 auto; margin-top: 1px;
  font-family: var(--mono); font-size: 10.5px; font-weight: 800; letter-spacing: .04em;
  color: #062a30; background: linear-gradient(180deg, #7fe9f5, var(--cyan));
  border: 1px solid #2aa7b6; border-radius: 5px; padding: 2px 6px;
  box-shadow: 0 0 12px -4px rgba(55,196,212,.6);
}

.info-group { border-top: 1px solid var(--border); padding-top: 16px; }
.info { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; font-size: 12.5px; }
.info dt { color: var(--muted); }
.info dd { margin: 0; color: var(--text); font-family: var(--mono); font-size: 12px; text-align: right;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===================== STATUS BAR ===================== */
.statusbar {
  display: flex; align-items: center; gap: 14px;
  padding: 0 14px;
  background: linear-gradient(180deg, var(--blue), #1a5aa6);
  color: #dbe8f7; font-size: 11.5px; font-family: var(--mono);
  border-top: 1px solid rgba(0,0,0,.35);
}
.statusbar .st-branch { font-weight: 700; color: #fff; }
.st-spacer { flex: 1; }
.st-sel { color: #cfe0f4; }
.st-cursor { color: #fff !important; }
.st-eng { opacity: .8; }

/* ===================== TOASTS ===================== */
.toasts { position: fixed; bottom: calc(var(--status-h) + 14px); right: 16px; z-index: 50;
  display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast {
  padding: 10px 15px; border-radius: 9px; font-size: 13px; font-weight: 600;
  background: var(--bg-3); color: var(--text); border: 1px solid var(--border-2);
  box-shadow: 0 12px 30px -10px rgba(0,0,0,.7);
  animation: toastIn .22s ease, toastOut .25s ease forwards; animation-delay: 0s, 2.7s;
  max-width: 320px;
}
.toast.ok { border-color: #2c8a3b; box-shadow: 0 0 0 1px rgba(63,185,80,.2), 0 12px 30px -10px rgba(0,0,0,.7); }
.toast.ok::before { content: "✓ "; color: var(--green-hi); }
.toast.err { border-color: var(--red-deep); }
.toast.err::before { content: "✕ "; color: var(--red-hi); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-6px); } }

/* ===================== RESPONSIVE ===================== */
@media (max-width: 860px) {
  body { grid-template-rows: auto 1fr var(--status-h); overflow: auto; }
  .workspace { grid-template-columns: 1fr; overflow: visible; }
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 14px; gap: 10px; }
  .brand-tag { display: none; }
  .editor { height: 62vh; }
  .panel { border-left: 0; border-top: 1px solid var(--border); }
  .panel-scroll { max-height: none; }
}
@media (max-width: 560px) {
  .toolbar .btn span, .btn-primary { font-size: 12px; }
  .time-readout { font-size: 12px; }
  .transport { gap: 8px; }
}
