:root {
  --bg: #100d17;
  --surface: rgba(28, 23, 39, 0.82);
  --surface-strong: #211b2d;
  --border: rgba(255, 255, 255, 0.09);
  --border-bright: rgba(255, 255, 255, 0.16);
  --text: #f8f4ff;
  --muted: #a9a0b7;
  --accent: #e9ff70;
  --accent-soft: rgba(233, 255, 112, 0.12);
  --purple: #a77bf3;
  --pink: #ff72a4;
  --danger: #ff8799;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
  --radius: 22px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { color-scheme: dark; }

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 0%, rgba(103, 66, 159, 0.18), transparent 32rem),
    radial-gradient(circle at 100% 100%, rgba(151, 58, 99, 0.13), transparent 34rem),
    var(--bg);
  font-family: "DM Sans", "Noto Sans JP", sans-serif;
  letter-spacing: 0.01em;
}

button, textarea, input { font: inherit; }
button { color: inherit; }

.ambient {
  position: fixed;
  z-index: -1;
  width: 24rem;
  height: 24rem;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.16;
  pointer-events: none;
}
.ambient-one { top: 7rem; left: -12rem; background: var(--purple); }
.ambient-two { right: -14rem; bottom: 3rem; background: var(--pink); }

.app-header {
  width: min(1500px, calc(100% - 64px));
  margin: 0 auto;
  padding: 30px 0 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(233, 255, 112, 0.35);
  border-radius: 14px;
  color: var(--accent);
  background: linear-gradient(145deg, rgba(233, 255, 112, 0.16), rgba(167, 123, 243, 0.12));
  box-shadow: inset 0 1px rgba(255,255,255,.14), 0 10px 25px rgba(0,0,0,.25);
  font-size: 1.25rem;
  font-weight: 700;
}

.eyebrow, .step-label {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.17em;
}

h1 { margin: 0; font-size: 1.3rem; line-height: 1.1; }
h1 span { margin-left: 6px; color: var(--muted); font-size: 0.75rem; font-weight: 500; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 14px var(--accent); }

.project-header { display: flex; align-items: center; gap: 16px; }
.project-identity { display: flex; min-width: 170px; flex-direction: column; align-items: flex-end; }
.save-state { color: var(--muted); font-size: .58rem; letter-spacing: .08em; }
.save-state.saved { color: var(--accent); }
.project-name {
  width: 190px;
  padding: 3px 0;
  outline: 0;
  border: 0;
  border-bottom: 1px solid transparent;
  color: var(--text);
  background: transparent;
  font-size: .76rem;
  font-weight: 600;
  text-align: right;
  transition: border-color .2s;
}
.project-name:focus { border-color: rgba(233,255,112,.4); }
.project-actions { display: flex; align-items: center; gap: 6px; }
.header-button, .save-project-button {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255,255,255,.035);
  cursor: pointer;
  font-size: .66rem;
  transition: .2s ease;
}
.header-button:hover:not(:disabled) { border-color: var(--border-bright); background: rgba(255,255,255,.07); }
.header-button:disabled { opacity: .35; cursor: default; }
.header-button svg, .save-project-button svg { width: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.project-count { display: grid; min-width: 18px; height: 18px; place-items: center; border-radius: 9px; color: var(--accent); background: var(--accent-soft); font-size: .58rem; }
.save-project-button { border-color: rgba(233,255,112,.25); color: #171313; background: var(--accent); font-weight: 700; }
.save-project-button:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(210,237,85,.15); }
.save-project-button:disabled { opacity: .55; cursor: wait; transform: none; }

.workspace {
  width: min(1500px, calc(100% - 64px));
  min-height: calc(100vh - 180px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(380px, 0.82fr) minmax(520px, 1.18fr);
  gap: 18px;
}

.glass-panel {
  min-height: 680px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow), inset 0 1px rgba(255,255,255,.04);
  backdrop-filter: blur(22px);
}

.input-panel, .results-panel { display: flex; min-width: 0; flex-direction: column; }

.panel-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 25px 27px 20px;
  border-bottom: 1px solid var(--border);
}

.panel-heading h2 { margin: 0; font-size: 1.22rem; letter-spacing: -0.02em; }
.input-actions { display: flex; gap: 6px; }
.text-button, .icon-button, .filter-chip {
  border: 0;
  cursor: pointer;
  transition: .2s ease;
}
.text-button { padding: 8px 10px; color: var(--muted); background: transparent; font-size: .76rem; }
.text-button:hover { color: var(--text); }
.text-button.danger:hover { color: var(--danger); }

.editor-shell { position: relative; display: flex; flex: 1; min-height: 480px; background: rgba(10, 8, 15, 0.32); }
.line-numbers {
  flex: 0 0 48px;
  overflow: hidden;
  padding: 22px 12px;
  color: rgba(169, 160, 183, .45);
  border-right: 1px solid var(--border);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.76rem;
  line-height: 1.8;
  text-align: right;
  white-space: pre;
  user-select: none;
}

#lyricsInput {
  width: 100%;
  min-height: 100%;
  resize: none;
  padding: 20px 22px;
  outline: 0;
  border: 0;
  color: #efeaf7;
  background: transparent;
  caret-color: var(--accent);
  font-family: "Noto Sans JP", sans-serif;
  font-size: .93rem;
  line-height: 1.8;
}
#lyricsInput::placeholder { color: rgba(169, 160, 183, .4); }

.input-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 17px 21px;
  border-top: 1px solid var(--border);
}
.input-footer p { margin: 0; color: var(--muted); font-size: .69rem; }
kbd { padding: 2px 5px; border: 1px solid var(--border-bright); border-radius: 5px; background: rgba(255,255,255,.04); font-size: .65rem; }

.primary-button {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px 12px 19px;
  border: 0;
  border-radius: 12px;
  color: #171313;
  background: var(--accent);
  box-shadow: 0 9px 26px rgba(210, 237, 85, .14);
  cursor: pointer;
  font-size: .78rem;
  font-weight: 700;
  transition: transform .2s, box-shadow .2s;
}
.primary-button:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(210, 237, 85, .23); }
.primary-button:active { transform: translateY(0); }
.primary-button:disabled { opacity: .55; cursor: wait; }
.primary-button svg { width: 16px; fill: none; stroke: currentColor; stroke-width: 2; }

.results-heading { align-items: center; }
.summary {
  display: flex;
  align-items: baseline;
  gap: 6px;
  color: var(--accent);
}
.summary span { font-size: 1.65rem; font-weight: 700; }
.summary small { color: var(--muted); font-size: .6rem; letter-spacing: .14em; }

.filter-bar {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 15px 22px;
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
}
.filter-bar::-webkit-scrollbar { display: none; }
.filter-chip {
  flex: 0 0 auto;
  padding: 7px 11px;
  border: 1px solid transparent;
  border-radius: 99px;
  color: var(--muted);
  background: rgba(255,255,255,.035);
  font-size: .68rem;
}
.filter-chip:hover { color: var(--text); border-color: var(--border); }
.filter-chip.active { color: #171313; background: var(--accent); font-weight: 700; }
.filter-chip.unavailable { opacity: .35; }

.results-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 54px;
  padding: 9px 22px;
  border-bottom: 1px solid var(--border);
}
.results-toolbar p { overflow: hidden; margin: 0; color: var(--muted); font-size: .7rem; text-overflow: ellipsis; white-space: nowrap; }
.icon-button {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 9px;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  font-size: .67rem;
}
.icon-button:hover:not(:disabled) { color: var(--text); background: rgba(255,255,255,.05); }
.icon-button:disabled { opacity: .35; cursor: default; }
.icon-button svg { width: 14px; fill: none; stroke: currentColor; stroke-width: 1.7; }

.empty-state { display: grid; flex: 1; place-content: center; padding: 40px; text-align: center; }
.empty-state h3 { margin: 25px 0 8px; font-size: .95rem; }
.empty-state p { margin: 0; color: var(--muted); font-size: .76rem; }
.empty-orbit { position: relative; width: 74px; height: 74px; margin: 0 auto; border: 1px solid rgba(233,255,112,.18); border-radius: 50%; }
.empty-orbit::after { content: ""; position: absolute; inset: 15px; border: 1px solid rgba(167,123,243,.26); border-radius: 50%; }
.empty-orbit span { position: absolute; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px rgba(233,255,112,.6); }
.empty-orbit span:nth-child(1) { top: -3px; left: 33px; }
.empty-orbit span:nth-child(2) { right: 6px; bottom: 8px; background: var(--purple); }
.empty-orbit span:nth-child(3) { left: 13px; bottom: 15px; width: 4px; height: 4px; }

.result-list { overflow-y: auto; flex: 1; min-height: 0; }
.section-block + .section-block { border-top: 1px solid var(--border); }
.section-title {
  position: sticky;
  z-index: 2;
  top: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 12px 22px 8px;
  color: var(--purple);
  background: rgba(25, 20, 35, .94);
  backdrop-filter: blur(10px);
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .11em;
  text-transform: uppercase;
}
.section-title::before { content: ""; width: 14px; height: 1px; background: currentColor; }

.result-row {
  display: grid;
  grid-template-columns: minmax(150px, .78fr) minmax(210px, 1.1fr) 58px;
  gap: 14px;
  align-items: center;
  padding: 12px 20px 12px 22px;
  transition: background .18s;
}
.result-row:hover { background: rgba(255,255,255,.025); }
.original-cell { min-width: 0; }
.original-cell small { display: block; margin-bottom: 3px; color: rgba(169,160,183,.45); font-size: .55rem; }
.original-cell p { overflow: hidden; margin: 0; font-family: "Noto Sans JP", sans-serif; font-size: .78rem; text-overflow: ellipsis; white-space: nowrap; }
.reading-input {
  width: 100%;
  padding: 8px 10px;
  outline: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: #d9d2e3;
  background: rgba(10,8,15,.32);
  font-family: "Noto Sans JP", sans-serif;
  font-size: .72rem;
  transition: border-color .2s, background .2s;
}
.reading-input:hover { border-color: var(--border-bright); }
.reading-input:focus { border-color: rgba(233,255,112,.55); background: rgba(10,8,15,.55); box-shadow: 0 0 0 3px rgba(233,255,112,.06); }
.count-badge {
  display: grid;
  width: 45px;
  height: 45px;
  place-items: center;
  justify-self: end;
  border: 1px solid rgba(233,255,112,.2);
  border-radius: 13px;
  color: var(--accent);
  background: var(--accent-soft);
  font-size: 1.1rem;
  font-weight: 700;
}

.app-footer {
  width: min(1500px, calc(100% - 64px));
  margin: 0 auto;
  padding: 17px 3px 28px;
  display: flex;
  justify-content: space-between;
  color: rgba(169,160,183,.62);
  font-size: .65rem;
}
.app-footer p { margin: 0; }
.app-footer span { margin-right: 7px; color: var(--accent); font-weight: 700; }

.toast {
  position: fixed;
  z-index: 20;
  right: 28px;
  bottom: 26px;
  padding: 12px 16px;
  border: 1px solid var(--border-bright);
  border-radius: 11px;
  opacity: 0;
  color: var(--text);
  background: #292233;
  box-shadow: var(--shadow);
  font-size: .76rem;
  transform: translateY(12px);
  transition: opacity .2s, transform .2s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }

.project-overlay {
  position: fixed;
  z-index: 30;
  inset: 0;
  display: flex;
  justify-content: flex-end;
  background: rgba(5, 3, 9, .64);
  backdrop-filter: blur(7px);
}
.project-drawer {
  width: min(420px, 92vw);
  height: 100%;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border-bright);
  background: #181320;
  box-shadow: -24px 0 80px rgba(0,0,0,.45);
  animation: drawer-in .22s ease-out;
}
@keyframes drawer-in { from { transform: translateX(28px); opacity: 0; } }
.drawer-header { display: flex; align-items: center; justify-content: space-between; padding: 28px 25px 21px; border-bottom: 1px solid var(--border); }
.drawer-header h2 { margin: 0; font-size: 1.24rem; }
.drawer-close { display: grid; width: 34px; height: 34px; place-items: center; border: 1px solid var(--border); border-radius: 10px; color: var(--muted); background: transparent; cursor: pointer; }
.drawer-close:hover { color: var(--text); border-color: var(--border-bright); }
.drawer-close svg { width: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.new-project-button {
  margin: 18px 20px 10px;
  padding: 12px 14px;
  border: 1px dashed rgba(233,255,112,.27);
  border-radius: 12px;
  color: var(--accent);
  background: rgba(233,255,112,.04);
  cursor: pointer;
  font-size: .73rem;
  text-align: left;
}
.new-project-button:hover { background: rgba(233,255,112,.08); }
.new-project-button span { margin-right: 6px; font-size: .95rem; }
.project-list { overflow-y: auto; flex: 1; padding: 8px 20px 20px; }
.project-card {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 7px 12px;
  width: 100%;
  margin-top: 8px;
  padding: 15px 14px;
  border: 1px solid var(--border);
  border-radius: 13px;
  color: var(--text);
  background: rgba(255,255,255,.025);
  text-align: left;
  transition: .18s ease;
}
.project-card:hover { border-color: rgba(233,255,112,.25); background: rgba(255,255,255,.045); }
.project-card.active { border-color: rgba(233,255,112,.38); background: var(--accent-soft); }
.project-card-main { min-width: 0; border: 0; color: inherit; background: transparent; cursor: pointer; text-align: left; }
.project-card-name { overflow: hidden; margin: 0 0 6px; font-size: .78rem; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.project-card-meta { margin: 0; color: var(--muted); font-size: .62rem; }
.project-delete { align-self: center; width: 30px; height: 30px; border: 0; border-radius: 8px; color: rgba(169,160,183,.55); background: transparent; cursor: pointer; }
.project-delete:hover { color: var(--danger); background: rgba(255,135,153,.08); }
.project-delete svg { width: 14px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.project-empty { padding: 70px 20px; color: var(--muted); text-align: center; font-size: .72rem; line-height: 1.8; }
.drawer-footer { display: flex; align-items: center; gap: 8px; padding: 16px 24px 22px; border-top: 1px solid var(--border); color: var(--muted); font-size: .64rem; }

@media (max-width: 980px) {
  .app-header, .workspace, .app-footer { width: min(100% - 28px, 760px); }
  .app-header { align-items: flex-start; gap: 20px; flex-direction: column; }
  .project-header { width: 100%; justify-content: space-between; }
  .project-identity { align-items: flex-start; }
  .project-name { text-align: left; }
  .workspace { grid-template-columns: 1fr; }
  .glass-panel { min-height: 610px; }
  .app-footer { gap: 10px; flex-direction: column; }
}

@media (max-width: 600px) {
  .app-header { padding-top: 18px; }
  .input-footer p { display: none; }
  .project-header { flex-wrap: wrap; gap: 8px; }
  .project-identity { width: 100%; align-items: flex-start; }
  .project-name { width: 100%; text-align: left; }
  .project-actions { width: 100%; }
  .header-button, .save-project-button { justify-content: center; flex: 1; padding: 0 8px; }
  .header-button.compact { flex: 0 0 47px; font-size: 0; }
  .header-button.compact svg { width: 17px; }
  .workspace { width: calc(100% - 18px); }
  .glass-panel { border-radius: 17px; }
  .panel-heading { padding: 21px 19px 17px; }
  .input-footer { justify-content: flex-end; }
  .result-row { grid-template-columns: 1fr 48px; gap: 8px; padding: 11px 14px 13px 18px; }
  .original-cell { grid-column: 1 / -1; }
  .count-badge { grid-column: 2; grid-row: 2; }
  .app-footer { width: calc(100% - 24px); }
}
