/* Audio Tag Editor — 全スタイル（ate- 接頭辞）。JS が作る DOM にも効かせるため、Astro のスコープ CSS ではなく外部 CSS にしている */
.ate-app {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 80px);
  min-height: 420px;
  margin-top: 40px;
  margin-bottom: 40px;
  background: #0d0d0d;
  color: #e0e0e0;
  font-family: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Yu Gothic UI", sans-serif;
  position: relative;
}

.ate-app *,
.ate-modal * {
  box-sizing: border-box;
}

.ate-app.drag::after {
  content: "ここにドロップ（音声ファイル / フォルダ / カバー画像）";
  position: absolute;
  inset: 0;
  background: #00ff8814;
  border: 2px dashed #00ff88;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: #00ff88;
  z-index: 5;
  pointer-events: none;
}

.ate-header {
  height: 48px;
  flex: none;
  background: #141414;
  border-bottom: 1px solid #222;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 8px;
}

.ate-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.ate-title {
  color: #00ff88;
  font-weight: bold;
  font-size: 14px;
  letter-spacing: 1px;
  white-space: nowrap;
}

.ate-badge {
  background: #1a3326;
  color: #00ff88;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid #00ff8844;
  white-space: nowrap;
}

.ate-header-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.ate-footer {
  min-height: 42px;
  flex: none;
  background: #141414;
  border-top: 1px solid #222;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 16px;
  gap: 12px;
}

.ate-status {
  font-size: 12px;
  color: #999;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ate-footer-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ate-hint {
  font-size: 11px;
  color: #666;
  white-space: nowrap;
}

.ate-kbd,
.ate-hint kbd {
  display: inline-block;
  border: 1px solid #444;
  border-bottom-width: 2px;
  border-radius: 3px;
  padding: 0 5px;
  font: 11px/16px ui-monospace, Consolas, monospace;
  color: #ccc;
  background: #1b1b1b;
}

.ate-main {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

.ate-panel-left {
  width: 340px;
  min-width: 300px;
  background: #111;
  border-right: 1px solid #222;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.ate-panel-center {
  flex: 1;
  background: #0a0a0a;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  position: relative;
  min-width: 0;
}

.ate-section-header {
  padding: 8px 12px;
  background: #181818;
  border-bottom: 1px solid #222;
  font-size: 12px;
  color: #aaa;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ate-link-btn {
  background: none;
  border: none;
  color: #00ff88;
  cursor: pointer;
  font-size: 11px;
  padding: 0 2px;
}

.ate-link-btn:hover {
  text-decoration: underline;
}

.ate-listbar {
  display: flex;
  gap: 6px;
  padding: 6px;
  border-bottom: 1px solid #1d1d1d;
}

.ate-listbar input,
.ate-listbar select {
  background: #1b1b1b;
  border: 1px solid #2c2c2c;
  color: #ddd;
  border-radius: 3px;
  padding: 4px 6px;
  font-size: 11px;
  min-width: 0;
}

.ate-listbar input {
  flex: 1;
}

.ate-file-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 80px;
}

.ate-empty-list {
  margin: auto;
  text-align: center;
  font-size: 12px;
  color: #666;
  line-height: 1.7;
  padding: 20px;
}

.ate-file-item {
  display: flex;
  align-items: center;
  padding: 6px 8px;
  background: #161616;
  border: 1px solid #222;
  border-radius: 4px;
  cursor: pointer;
  gap: 8px;
  font-size: 12px;
  flex: none;
}

.ate-file-item:hover {
  border-color: #333;
  background: #1c1c1c;
}

.ate-file-item.active {
  border-color: #00ff88;
  background: #00ff8810;
}

.ate-file-item input[type=checkbox] {
  flex: none;
  accent-color: #00ff88;
}

.ate-item-main {
  flex: 1;
  min-width: 0;
}

.ate-item-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ate-item-title.ph {
  color: #888;
}

.ate-item-sub {
  font-size: 10px;
  color: #777;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 1px;
}

.ate-item-tag {
  font-size: 10px;
  color: #777;
  background: #222;
  padding: 1px 4px;
  border-radius: 3px;
  flex: none;
  text-transform: uppercase;
}

.ate-dot {
  flex: none;
  font-size: 11px;
  width: 14px;
  text-align: center;
}

.ate-dot.dirty {
  color: #e6b422;
}

.ate-dot.saved {
  color: #00ff88;
}

.ate-dot.error {
  color: #ff5555;
}

.ate-batch-section {
  padding: 10px 12px;
  background: #141414;
  border-top: 1px solid #222;
  flex: none;
}

.ate-section-title {
  font-size: 11px;
  color: #00ff88;
  font-weight: bold;
  margin-bottom: 6px;
  letter-spacing: .5px;
}

.ate-batch-row {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
}

.ate-batch-row select,
.ate-batch-row input {
  background: #1e1e1e;
  border: 1px solid #333;
  color: #fff;
  padding: 5px 6px;
  border-radius: 3px;
  font-size: 11px;
  min-width: 0;
}

.ate-batch-row select {
  width: 96px;
  flex: none;
}

.ate-batch-row input {
  flex: 1;
}

.ate-batch-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.ate-centered-empty {
  margin: auto;
  text-align: center;
  color: #666;
  font-size: 13px;
  line-height: 1.8;
  padding: 20px;
}

.ate-big-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: .5;
}

.ate-editor-form {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.ate-editor-header {
  border-bottom: 1px solid #222;
  padding-bottom: 10px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.ate-file-title {
  font-size: 17px;
  font-weight: bold;
  color: #fff;
  word-break: break-all;
}

.ate-file-meta {
  font-size: 12px;
  color: #777;
  margin-top: 4px;
}

.ate-notice {
  font-size: 11px;
  color: #e6b422;
  margin-top: 4px;
}

.ate-editor-grid {
  display: flex;
  gap: 24px;
}

.ate-cover-area {
  width: 170px;
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.ate-cover-box {
  width: 170px;
  height: 170px;
  background: #141414;
  border: 2px dashed #333;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  position: relative;
}

.ate-cover-box:hover,
.ate-cover-box.over {
  border-color: #00ff88;
}

.ate-cover-box.off {
  cursor: not-allowed;
  opacity: .6;
}

.ate-cover-box.changed {
  border-color: #e6b422;
  border-style: solid;
}

.ate-cover-box img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.ate-cover-placeholder {
  text-align: center;
  color: #666;
  font-size: 11px;
  line-height: 1.5;
}

.ate-cover-placeholder span {
  font-size: 28px;
  display: block;
  margin-bottom: 4px;
}

.ate-cover-info {
  font-size: 10px;
  color: #777;
  text-align: center;
  min-height: 14px;
}

.ate-cover-btns {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: center;
}

.ate-cover-opt {
  font-size: 10px;
  color: #888;
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
}

.ate-cover-opt select {
  background: #1b1b1b;
  color: #ccc;
  border: 1px solid #2c2c2c;
  border-radius: 3px;
  font-size: 10px;
  padding: 2px;
}

.ate-fields-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.ate-form-row {
  display: flex;
  gap: 12px;
}

.ate-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.ate-field label {
  font-size: 11px;
  color: #888;
}

.ate-input {
  background: #161616;
  border: 1px solid #2a2a2a;
  color: #fff;
  padding: 8px 10px;
  border-radius: 4px;
  font-size: 13px;
  width: 100%;
  font-family: inherit;
}

.ate-input:focus {
  border-color: #00ff88;
  outline: none;
}

.ate-input.changed {
  border-color: #e6b422;
  background: #1d1a10;
}

.ate-input:disabled {
  opacity: .35;
  cursor: not-allowed;
}

textarea.ate-input {
  resize: vertical;
  min-height: 96px;
  line-height: 1.5;
}

.ate-more {
  border-top: 1px solid #1e1e1e;
  padding-top: 8px;
}

.ate-more summary {
  cursor: pointer;
  font-size: 12px;
  color: #9a9a9a;
  margin-bottom: 10px;
}

.ate-editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid #222;
}

.ate-btn {
  background: #222;
  color: #ccc;
  border: 1px solid #333;
  padding: 8px 14px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  transition: all .15s;
  font-family: inherit;
}

.ate-btn:hover {
  border-color: #00ff88;
  color: #00ff88;
}

.ate-btn:disabled {
  opacity: .3;
  cursor: not-allowed;
  border-color: #333 !important;
  color: #ccc !important;
}

.ate-btn-sm {
  padding: 4px 10px;
  font-size: 11px;
}

.ate-btn-xs {
  padding: 2px 6px;
  font-size: 10px;
}

.ate-btn-primary {
  background: #00ff8820;
  border-color: #00ff88;
  color: #00ff88;
  font-weight: bold;
}

.ate-btn-primary:hover {
  background: #00ff8835;
}

.ate-btn-secondary {
  background: #1a1a1a;
  border-color: #333;
  font-size: 11px;
  padding: 5px 10px;
}

.ate-btn-danger {
  color: #ff5555;
  border-color: #ff555544;
}

.ate-btn-danger:hover {
  background: #ff555520;
  border-color: #ff5555;
  color: #ff5555;
}

/* 通知・メニュー・ダイアログ */
.ate-toast {
  position: fixed;
  left: 50%;
  bottom: 90px;
  transform: translateX(-50%);
  background: #1c2a22;
  color: #d8ffe9;
  border: 1px solid #00ff8855;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  z-index: 10000;
  max-width: 80vw;
  box-shadow: 0 4px 18px #000a;
}

.ate-toast.err {
  background: #2a1717;
  color: #ffd5d5;
  border-color: #ff555588;
}

.ate-menu {
  position: fixed;
  z-index: 9999;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 6px;
  padding: 4px 0;
  min-width: 230px;
  box-shadow: 0 6px 24px #000c;
  font-size: 12px;
}

.ate-menu div {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 6px 14px;
  cursor: pointer;
  color: #ddd;
}

.ate-menu div:hover {
  background: #00ff8818;
  color: #00ff88;
}

.ate-menu div.off {
  opacity: .35;
  cursor: default;
}

.ate-menu div.off:hover {
  background: none;
  color: #ddd;
}

.ate-menu div b {
  font-weight: normal;
}

.ate-menu div span {
  color: #777;
  font-size: 11px;
}

.ate-menu hr {
  border: 0;
  border-top: 1px solid #2a2a2a;
  margin: 4px 0;
}

.ate-modal-bg {
  position: fixed;
  inset: 0;
  background: #000a;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.ate-modal {
  background: #151515;
  color: #e0e0e0;
  border: 1px solid #333;
  border-radius: 8px;
  width: min(480px, 100%);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 40px #000;
  font-family: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Yu Gothic UI", sans-serif;
}

.ate-modal.wide {
  width: min(760px, 100%);
}

.ate-modal .hd {
  padding: 12px 16px;
  border-bottom: 1px solid #2a2a2a;
  font-weight: bold;
  font-size: 14px;
  color: #00ff88;
  display: flex;
  justify-content: space-between;
}

.ate-modal .hd .x {
  cursor: pointer;
  color: #888;
  font-size: 18px;
  line-height: 14px;
}

.ate-modal .hd .x:hover {
  color: #fff;
}

.ate-modal .bd {
  padding: 14px 16px;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.6;
}

.ate-modal .ft {
  padding: 10px 16px;
  border-top: 1px solid #2a2a2a;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.ate-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ate-form .row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ate-form .row>label,
.ate-form .lbl {
  font-size: 11px;
  color: #999;
}

.ate-form .inline {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  font-size: 12px;
}

.ate-form input[type=text],
.ate-form input[type=number],
.ate-form select {
  background: #1b1b1b;
  border: 1px solid #333;
  color: #fff;
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 13px;
  width: 100%;
  font-family: inherit;
}

.ate-form input[type=checkbox],
.ate-form input[type=radio] {
  accent-color: #00ff88;
}

.ate-form label.chk {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 12px;
  color: #ddd;
  cursor: pointer;
}

.ate-form .note {
  font-size: 11px;
  color: #888;
}

.ate-prev {
  font-size: 11px;
  color: #aaa;
  background: #0f0f0f;
  border: 1px solid #222;
  border-radius: 4px;
  padding: 6px 8px;
  max-height: 140px;
  overflow: auto;
  line-height: 1.6;
  word-break: break-all;
}

.ate-prev .ng {
  color: #ff8888;
}

.ate-bar {
  height: 6px;
  background: #222;
  border-radius: 3px;
  overflow: hidden;
}

.ate-bar i {
  display: block;
  height: 100%;
  width: 0;
  background: #00ff88;
  transition: width .15s;
}

.ate-log {
  font-size: 11px;
  max-height: 180px;
  overflow: auto;
  background: #0f0f0f;
  border: 1px solid #222;
  border-radius: 4px;
  padding: 6px 8px;
  line-height: 1.6;
  word-break: break-all;
}

.ate-log .ok {
  color: #6fe3a4;
}

.ate-log .ng {
  color: #ff8888;
}

/* ヘルプ */
.ate-help input.q {
  width: 100%;
  background: #181818;
  border: 1px solid #333;
  color: #fff;
  border-radius: 4px;
  padding: 8px 10px;
  font-size: 13px;
  margin-bottom: 8px;
}

.ate-help h3 {
  font-size: 13px;
  color: #00ff88;
  margin: 14px 0 6px;
  border-bottom: 1px solid #222;
  padding-bottom: 3px;
}

.ate-help .qa {
  margin: 6px 0 10px;
}

.ate-help .qa b {
  display: block;
  color: #fff;
  font-size: 13px;
}

.ate-help .qa span {
  display: block;
  color: #bbb;
  font-size: 12px;
  padding-left: 10px;
  white-space: pre-wrap;
}

.ate-help .hide {
  display: none;
}

.ate-help .keys {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 4px 14px;
  font-size: 12px;
  color: #ccc;
}

.ate-help .keys span.d {
  margin-left: 8px;
  color: #aaa;
}

@media (max-width:820px) {
  .ate-main {
    flex-direction: column;
    overflow-y: auto;
  }

  .ate-panel-left {
    width: 100%;
    min-width: 0;
    height: 46vh;
    flex: none;
    border-right: 0;
    border-bottom: 1px solid #222;
  }

  .ate-editor-grid {
    flex-direction: column;
    align-items: center;
  }

  .ate-fields-area {
    width: 100%;
  }

  .ate-form-row {
    flex-direction: column;
  }

  .ate-hint {
    display: none;
  }
}
