:root {
  --bg: #0f1115;
  --fg: #e6e6e6;
  --muted: #9aa0a6;
  --acc: #7aa2f7;
  --warn: #f6bd60;
  --ok: #34d399;
  --err: #f06272;
  --card: #151a22;
  --border: #2a2f3a;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", sans-serif;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 700;
}

h1 {
  font-size: 24px;
}

h2 {
  font-size: 18px;
}

h3 {
  font-size: 16px;
  margin-bottom: 8px;
}

.app {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px 24px 32px;
}

.app>header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 18px;
  gap: 12px;
  flex-wrap: wrap;
}

.subtitle {
  color: var(--muted);
  font-size: 13px;
}

.layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr) 280px;
  gap: 18px;
}

@media (max-width: 1200px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar,
  .main,
  .log-panel {
    order: initial;
  }
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 480px;
}

.bag-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bag-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(15, 20, 30, 0.6);
  overflow: hidden;
  position: relative;
}

.bag-card.dragging {
  opacity: 0.55;
}

.bag-card.drag-over::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(122, 162, 247, 0.75);
  top: 0;
}

.bag-card>summary {
  cursor: pointer;
  padding: 10px 12px;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.bag-card>summary::-webkit-details-marker {
  display: none;
}

.bag-title {
  font-size: 14px;
  font-weight: 600;
}

.bag-meta {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  color: var(--muted);
  padding: 0 12px 12px;
  white-space: pre-wrap;
}

.preview-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 12px 10px;
  align-items: center;
}

.preview-bar label {
  display: flex;
  gap: 4px;
  align-items: center;
  color: var(--muted);
}

.preview {
  width: 100%;
  border: none;
  border-top: 1px solid var(--border);
  padding: 12px;
  background: rgba(8, 10, 16, 0.6);
  color: var(--fg);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  resize: vertical;
}

.btn {
  cursor: pointer;
  background: #1e2530;
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 7px 12px;
  border-radius: 10px;
  transition: all 0.15s ease;
  font-weight: 600;
}

.btn:hover {
  border-color: var(--acc);
  box-shadow: 0 0 0 2px rgba(122, 162, 247, 0.15) inset;
}

.btn.primary {
  background: linear-gradient(180deg, #1f2a44, #1a2136);
  border-color: #304571;
  color: #e7efff;
}

.btn.warn {
  background: #3a2a17;
  border-color: #6b4d27;
  color: #ffe7ba;
}

.btn.ok {
  background: #11261f;
  border-color: #1f6b53;
  color: #cafdf0;
}

.btn.ghost {
  background: transparent;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
  border-color: var(--border);
}

.input,
textarea,
select {
  width: 100%;
  padding: 8px 10px;
  color: var(--fg);
  background: #10151e;
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
}

textarea {
  resize: vertical;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 12px;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

.tight {
  max-width: 200px;
}

.tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.tab-button {
  border-radius: 999px;
  padding: 8px 16px;
  border: 1px solid transparent;
  background: rgba(16, 21, 30, 0.6);
  color: var(--muted);
}

.tab-button.active {
  color: var(--fg);
  background: rgba(122, 162, 247, 0.18);
  border-color: rgba(122, 162, 247, 0.4);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.panel-grid {
  display: grid;
  gap: 12px;
}

.grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.log-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 480px;
}

.log-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.log-body {
  background: rgba(8, 10, 16, 0.55);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  height: 200px;
  overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  color: var(--muted);
}

.log-entry+.log-entry {
  margin-top: 6px;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  background: rgba(122, 162, 247, 0.15);
  color: var(--acc);
}

.op-group {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: rgba(15, 20, 30, 0.6);
  display: grid;
  gap: 10px;
}

.op-group h4 {
  font-size: 14px;
  margin: 0;
  cursor: pointer;
  user-select: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.op-group h4::after {
  content: '▼';
  font-size: 10px;
  color: var(--muted);
  transition: transform 0.2s;
}

.op-group.closed h4::after {
  transform: rotate(-90deg);
}

.op-group.closed>*:not(h4) {
  display: none;
}

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

.inline>* {
  margin: 0;
  align-self: center;
}

.inline .input {
  max-width: 160px;
}

.history-actions {
  display: flex;
  gap: 8px;
}

.export-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.bag-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 0 12px 12px;
  align-items: center;
}

.bag-actions .status {
  flex: 1;
  min-width: 140px;
}
