/* ─── Reset & Base ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #e1e4e8;
  --text: #24292e;
  --text-secondary: #6a737d;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --sidebar-bg: #1e293b;
  --sidebar-text: #cbd5e1;
  --sidebar-active: #334155;
  --sidebar-hover: #2d3a4d;
  --shadow: 0 1px 3px rgba(0,0,0,.08);
  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* ─── Buttons ─── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border: none; border-radius: var(--radius);
  font-size: 14px; font-weight: 500; cursor: pointer;
  transition: background .15s, box-shadow .15s;
  font-family: var(--font);
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: rgba(0,0,0,.05); color: var(--text); }
.btn-danger { background: transparent; color: var(--danger); }
.btn-danger:hover { background: rgba(220,38,38,.08); }
.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border: none; border-radius: 6px;
  background: transparent; cursor: pointer; font-size: 14px;
  color: var(--text-secondary); transition: background .15s;
}
.btn-icon:hover { background: rgba(0,0,0,.06); }
.btn-full { width: 100%; }
.btn-sm { padding: 4px 10px; font-size: 13px; }

/* ─── Layout ─── */
.app-layout { display: flex; min-height: 100vh; }

/* ─── Sidebar ─── */
.sidebar {
  width: 220px; min-width: 220px;
  background: var(--sidebar-bg); color: var(--sidebar-text);
  display: flex; flex-direction: column;
  transition: width .2s, min-width .2s;
}
.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px; border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-logo { font-size: 20px; font-weight: 700; color: #fff; }
.sidebar-header .btn-icon { color: var(--sidebar-text); }
.sidebar-header .btn-icon:hover { background: var(--sidebar-hover); }

.project-list { flex: 1; overflow-y: auto; padding: 8px; }
.project-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-radius: 6px; cursor: pointer;
  margin-bottom: 2px; transition: background .12s; font-size: 14px;
}
.project-item:hover { background: var(--sidebar-hover); }
.project-item.active { background: var(--sidebar-active); color: #fff; }
.project-item-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-item-actions { display: flex; gap: 2px; opacity: 0; transition: opacity .12s; }
.project-item:hover .project-item-actions { opacity: 1; }
.project-item-actions .btn-icon { width: 26px; height: 26px; font-size: 12px; color: var(--sidebar-text); }
.project-item-actions .btn-icon:hover { background: rgba(255,255,255,.1); }

.sidebar-footer { padding: 12px; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-footer .btn { background: rgba(255,255,255,.1); color: #fff; }
.sidebar-footer .btn:hover { background: rgba(255,255,255,.18); }

/* Sidebar collapsed */
.sidebar.collapsed { width: 0; min-width: 0; overflow: hidden; padding: 0; }
.sidebar-mini { width: 40px; background: var(--sidebar-bg); display: flex; align-items: flex-start; padding-top: 16px; justify-content: center; }
.sidebar-mini .btn-icon { color: var(--sidebar-text); }

/* ─── Main Area ─── */
.main-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px; background: var(--surface); border-bottom: 1px solid var(--border);
  gap: 16px;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-left h2 { font-size: 18px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

.lang-select {
  padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 13px; font-family: var(--font); background: var(--surface); outline: none;
  cursor: pointer;
}
.lang-select:focus { border-color: var(--primary); }

.inline-new-project {
  width: 100%; padding: 8px 10px; border: 1px solid rgba(255,255,255,.3);
  border-radius: 6px; font-size: 14px; font-family: var(--font);
  background: rgba(255,255,255,.1); color: #fff; outline: none;
}
.inline-new-project::placeholder { color: rgba(255,255,255,.5); }
.inline-new-project:focus { border-color: rgba(255,255,255,.6); background: rgba(255,255,255,.15); }

.inline-rename-input {
  flex: 1; padding: 4px 8px; border: 1px solid var(--primary); border-radius: 4px;
  font-size: 14px; font-family: var(--font); background: #fff; outline: none;
  color: var(--text);
}

.project-notes-area {
  padding: 0 24px; margin-top: 8px;
}
.project-notes-input {
  width: 100%; padding: 10px 14px; border: 1px solid var(--border);
  border-radius: 6px; font-size: 13px; font-family: var(--font);
  resize: none; overflow: hidden; outline: none; background: var(--surface);
  color: var(--text-secondary); line-height: 1.5;
  transition: border-color .15s, color .15s;
}
.project-notes-input:focus { border-color: var(--primary); color: var(--text); }

.cards-container {
  flex: 1; overflow-y: auto; padding: 24px;
  display: flex; flex-direction: column; gap: 16px;
}
.empty-hint { color: var(--text-secondary); text-align: center; padding: 60px 20px; font-size: 15px; }

/* ─── Card ─── */
.card {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 20px;
  position: relative;
}
.card-actions {
  position: absolute; top: 12px; right: 12px;
  display: flex; gap: 4px; opacity: 0; transition: opacity .12s;
}
.card:hover .card-actions { opacity: 1; }

.card-col { display: flex; flex-direction: column; gap: 8px; }
.card-col-header { font-size: 12px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: .5px; }

.card-notes-row { grid-column: 1 / -1; }
.card-notes-text {
  width: 100%; padding: 6px 10px; border: 1px solid var(--border);
  border-radius: 4px; font-size: 12px; font-family: var(--font);
  resize: none; overflow: hidden; outline: none; background: #fafbfc;
  color: var(--text-secondary); line-height: 1.5;
  transition: border-color .15s, color .15s;
}
.card-notes-text:focus { border-color: var(--primary); color: var(--text); }

.card-field { position: relative; }
.card-field textarea {
  width: 100%; padding: 10px 40px 10px 12px;
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 15px; font-family: var(--font); line-height: 1.6;
  resize: none; overflow: hidden; outline: none; background: #fafbfc;
  transition: border-color .15s, background .15s;
}
.card-field textarea:focus { border-color: var(--primary); background: #fff; }
.card-field textarea.main-text { font-size: 16px; }
.card-field textarea.sub-text { font-size: 13px; color: var(--text-secondary); }

.card-play-btn {
  position: absolute; top: 8px; right: 6px;
  width: 30px; height: 30px; border: none; border-radius: 50%;
  background: var(--primary); color: #fff; cursor: pointer;
  font-size: 14px; display: flex; align-items: center; justify-content: center;
  transition: background .15s, transform .1s;
  z-index: 2;
}
.card-play-btn:hover { background: var(--primary-hover); }
.card-play-btn:active { transform: scale(.92); }
.card-play-btn.playing { background: var(--danger); animation: pulse 1s infinite; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,.4); }
  50% { box-shadow: 0 0 0 8px rgba(220,38,38,0); }
}

/* ─── Toast ─── */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #24292e; color: #fff; padding: 10px 20px;
  border-radius: 8px; font-size: 14px; z-index: 999;
  animation: toast-in .25s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translateX(-50%) translateY(10px); } }
