* {
  box-sizing: border-box;
}

:root {
  --bg: #101114;
  --panel: #181a20;
  --panel2: #20232b;
  --text: #ffffff;
  --muted: #9da3b0;
  --primary: #7c5cff;
  --primary2: #9a82ff;
  --danger: #ff4f64;
  --green: #20c997;
  --border: #30333d;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

button,
textarea,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.topbar {
  min-height: 80px;
  padding: 18px 30px;
  border-bottom: 1px solid var(--border);

  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar h1 {
  margin: 0;
  font-size: 24px;
}

.topbar p {
  margin: 5px 0 0;
  color: var(--muted);
}

.badge {
  background: var(--green);
  color: #061b14;
  font-weight: 800;
  padding: 7px 12px;
  border-radius: 30px;
}

.app {
  max-width: 1250px;
  margin: auto;
  padding: 30px;

  display: grid;
  grid-template-columns: 1fr 430px;
  gap: 30px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
}

.panel h2 {
  margin-top: 0;
}

.panel h3 {
  margin-top: 28px;
}

.character-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}

.char-tab {
  flex: 1;
  padding: 13px;
  background: var(--panel2);
  color: white;
  border-radius: 12px;
}

.char-tab.active {
  background: var(--primary);
}

label {
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
}

textarea {
  width: 100%;
  resize: vertical;
  background: #0e0f13;
  color: white;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 15px;
  outline: none;
}

textarea:focus {
  border-color: var(--primary);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.controls button,
.play-controls button,
.record-controls button {
  padding: 12px 18px;
  border-radius: 12px;
  background: var(--panel2);
  color: white;
}

button.primary,
button.play {
  background: var(--primary);
}

button.primary:hover,
button.play:hover {
  background: var(--primary2);
}

button.danger {
  color: #ff8291;
}

.script-list {
  min-height: 100px;
  max-height: 330px;
  overflow-y: auto;
}

.script-empty {
  color: var(--muted);
  text-align: center;
  padding: 30px 10px;
}

.script-item {
  display: flex;
  gap: 12px;
  padding: 13px;
  margin-bottom: 10px;
  background: var(--panel2);
  border-radius: 12px;
}

.script-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;

  display: flex;
  align-items: center;
  justify-content: center;

  background: var(--primary);
  flex-shrink: 0;
}

.script-content {
  flex: 1;
}

.script-name {
  font-size: 12px;
  color: var(--primary2);
  font-weight: 800;
}

.script-text {
  margin-top: 3px;
  line-height: 1.5;
}

.delete-line {
  background: transparent;
  color: #ff7586;
  font-size: 18px;
}

.play-controls {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.play-controls button {
  flex: 1;
}

.voice-settings {
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

select {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  background: #0e0f13;
  color: white;
  border: 1px solid var(--border);
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 15px;
  color: var(--muted);
}

.checkbox input {
  width: 18px;
  height: 18px;
}


/* PHONE */

.preview-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.phone {
  width: min(100%, 300px);
  aspect-ratio: 9 / 16;

  background: black;
  border-radius: 25px;
  overflow: hidden;

  box-shadow:
    0 15px 50px rgba(0, 0, 0, 0.5);

  border: 6px solid #292b32;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.record-controls {
  width: 100%;
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.record-controls button {
  flex: 1;
}

.record {
  background: var(--danger) !important;
}

.recording {
  animation: pulse 1s infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.5;
  }
}

.status {
  color: var(--muted);
  font-size: 14px;
}

footer {
  padding: 25px;
  text-align: center;
  color: var(--muted);
  border-top: 1px solid var(--border);
}


/* MOBILE */

@media (max-width: 850px) {

  .topbar {
    padding: 15px;
  }

  .topbar p {
    font-size: 13px;
  }

  .app {
    grid-template-columns: 1fr;
    padding: 15px;
  }

  .panel {
    padding: 18px;
  }

  .preview-panel {
    order: -1;
  }

  .phone {
    width: min(82vw, 320px);
  }

}


/* =====================================================
   VOICE STUDIO
===================================================== */

.voice-settings {
  margin-top: 25px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.voice-settings h3 {
  margin-top: 0;
  margin-bottom: 6px;
}

.voice-help {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.voice-character {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 15px;
  margin-top: 12px;
}

.voice-title {
  font-weight: 800;
  margin-bottom: 12px;
}

.voice-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.voice-buttons button,
.upload-btn {
  padding: 9px 12px;
  border-radius: 9px;
  background: #101114;
  color: white;
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 13px;
}

.voice-buttons button:hover,
.upload-btn:hover {
  background: var(--primary);
}

.upload-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.voice-character audio {
  width: 100%;
  margin-top: 12px;
  height: 38px;
}

.voice-status {
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}

.voice-mode {
  margin-top: 18px;
}

.voice-mode select {
  margin-top: 7px;
}



/* =====================================================
   PHASE 2.1 - SCRIPT EXPRESSION UI
===================================================== */

.script-item {
  display: flex;
  flex-direction: column;
  gap: 12px;

  padding: 14px;

  margin-bottom: 10px;

  border: 1px solid #ddd;

  border-radius: 14px;

  background: #fff;
}


.script-main {
  display: flex;
  align-items: center;
  gap: 12px;
}


.script-character {
  min-width: 105px;

  padding: 7px 10px;

  border-radius: 10px;

  font-weight: 700;

  text-align: center;
}


.character-a {
  background: #dbeafe;
  color: #1d4ed8;
}


.character-b {
  background: #fce7f3;
  color: #be185d;
}


.script-text {
  flex: 1;

  font-size: 15px;

  line-height: 1.5;

  word-break: break-word;
}


.script-actions {
  display: flex;

  align-items: center;

  gap: 8px;

  flex-wrap: wrap;
}


.expression-label {
  font-size: 13px;

  font-weight: 600;

  color: #555;
}


.expression-select {
  min-width: 150px;

  padding: 8px 10px;

  border: 1px solid #ccc;

  border-radius: 9px;

  background: white;

  font-size: 14px;

  cursor: pointer;
}


.expression-select:focus {
  outline: 2px solid #93c5fd;

  border-color: #60a5fa;
}


.delete-dialogue {
  padding: 8px 12px;

  border: 0;

  border-radius: 9px;

  background: #fee2e2;

  color: #b91c1c;

  cursor: pointer;

  font-weight: 600;
}


.delete-dialogue:hover {
  background: #fecaca;
}


@media (max-width: 600px) {

  .script-main {
    align-items: flex-start;

    flex-direction: column;
  }

  .script-character {
    min-width: auto;
  }

  .expression-select {
    width: 100%;
  }

}


/* =========================================================
   SCRIPT EXPRESSION SELECT FIX
========================================================= */

.expression-select {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;

  background: #1f2430;
  color: #ffffff;

  border: 2px solid #3b4354;
  border-radius: 10px;

  font-size: 16px;
  font-weight: 600;

  cursor: pointer;
  outline: none;
}

/* When selected / focused */
.expression-select:focus {
  border-color: #8b5cf6;
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

/* Dropdown options */
.expression-select option {
  background: #1f2430;
  color: #ffffff;

  padding: 10px;
  font-size: 16px;
}

/* Hover-ish browser styling */
.expression-select:hover {
  border-color: #6366f1;
}


/* =========================================================
   SCRIPT ITEM
========================================================= */

.script-item {
  background: #ffffff;
  color: #1f2937;

  border: 1px solid #e5e7eb;
  border-radius: 16px;

  padding: 18px;
  margin-bottom: 14px;

  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}


/* Character name */
.script-character {
  font-weight: 700;
  font-size: 15px;

  margin-bottom: 8px;
}


/* Character 1 */
.script-character.character-a {
  color: #2563eb;
}


/* Character 2 */
.script-character.character-b {
  color: #16a34a;
}


/* Dialogue text */
.script-text {
  color: #374151;

  font-size: 16px;
  line-height: 1.5;

  margin-bottom: 14px;
}


/* Expression label */
.expression-label {
  display: block;

  color: #4b5563;

  font-size: 14px;
  font-weight: 600;

  margin-bottom: 6px;
}


/* Actions area */
.script-actions {
  margin-top: 12px;
}


/* Delete button */
.delete-dialogue {
  margin-top: 10px;

  background: #fee2e2;
  color: #dc2626;

  border: 1px solid #fecaca;
  border-radius: 8px;

  padding: 8px 12px;

  font-weight: 600;
  cursor: pointer;
}

.delete-dialogue:hover {
  background: #fecaca;
}


/* Selected Script */
.script-item.selected {
  background: #e0f2fe;
  border: 2px solid #0ea5e9;
  box-shadow: 0 4px 14px rgba(14, 165, 233, 0.25);

  position: relative;
}

/* Tick Mark */
.script-item.selected::before {
  content: "\f00c";

  font-family: "Font Awesome 6 Free";
  font-weight: 900;

  position: absolute;

  top: 12px;
  right: 12px;

  width: 26px;
  height: 26px;

  display: flex;
  align-items: center;
  justify-content: center;

  background: #0ea5e9;
  color: #ffffff;

  border-radius: 50%;

  font-size: 13px;
}

/* Selected dialogue text */
.script-item.selected .script-text {
  color: #0369a1;
  font-weight: 700;
}

/* Selected character name */
.script-item.selected .script-character {
  color: #0284c7;
  font-weight: 800;
}





