:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --text: #1d2129;
  --muted: #6b7280;
  --accent: #1677ff;
  --line: #e5e6eb;
  --input: #ffffff;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "IBM Plex Sans", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: 24px;
}
header h1 { margin: 0 0 4px; font-size: 28px; letter-spacing: 0.02em; }
header p { margin: 0 0 16px; color: var(--muted); }
.header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
}
.header-row p { margin-bottom: 0; }
.header-user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--muted);
  white-space: nowrap;
}
.login-gate {
  min-height: 60vh;
  display: grid;
  place-items: center;
}
.login-gate[hidden] { display: none !important; }
.login-card {
  width: min(360px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 22px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-card h2 { margin: 0 0 4px; font-size: 20px; }
.login-card label { width: 100%; }
.login-card input { width: 100%; }
.login-card button[type="submit"] { width: 100%; margin-top: 4px; }
.login-err { margin: 0; color: #c00; font-size: 13px; }
button.ghost {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
}
.tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tabs a {
  display: inline-flex;
  align-items: center;
  height: 36px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}
.tabs a.active {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}
.crumb { margin: 0 0 12px; }
.crumb a { color: var(--accent); text-decoration: none; }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 16px;
}
.panel h2, .panel h3 { margin-top: 0; }
form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 16px;
}
label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}
input, select, button {
  font: inherit;
  height: 36px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--input);
  color: var(--text);
}
button {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}
.row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { border-bottom: 1px solid var(--line); padding: 8px 6px; text-align: left; vertical-align: middle; }
tr:hover td { background: #f7f9fc; }
.toast {
  position: fixed; right: 16px; bottom: 16px;
  background: #fff; color: var(--text); border: 1px solid var(--accent);
  padding: 10px 14px; border-radius: 8px;
}
.muted { color: var(--muted); font-size: 12px; }
.linkish {
  color: var(--accent); cursor: pointer; background: none; border: none;
  padding: 0; height: auto; font-weight: 500;
}
button.danger {
  background: #fff;
  color: #cf1322;
  border: 1px solid #ffa39e;
  margin-left: 6px;
}
button.danger.sm {
  height: 32px;
  padding: 0 10px;
  font-weight: 500;
}
.row-actions {
  white-space: nowrap;
}
.row-actions .linkish {
  margin-right: 4px;
}
button.danger.solid {
  background: #cf1322;
  color: #fff;
  border-color: #cf1322;
  margin-left: 0;
}
button.ghost {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
}
button.ghost.sm {
  height: 32px;
  padding: 0 10px;
  font-weight: 500;
  margin-right: 6px;
}
.modal-form {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
}
.modal-form .modal-actions {
  margin-top: 4px;
}
.modal[hidden] { display: none !important; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}
.modal-card {
  position: relative;
  width: min(400px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px 20px 16px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.18);
}
.modal-card h3 {
  margin: 0 0 8px;
  font-size: 18px;
  color: var(--text);
}
.modal-msg {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
img.cover {
  width: 48px;
  height: 72px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--line);
  vertical-align: middle;
}
.cover-editor {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 16px;
  margin: 16px 0 8px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.cover-preview {
  width: 96px;
  height: 144px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fafbfc;
  display: grid;
  place-items: center;
  overflow: hidden;
  flex-shrink: 0;
}
img.drama-cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.cover-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  min-width: 220px;
}
.cover-file {
  display: inline-flex;
  flex-direction: column;
  gap: 6px;
}
.cover-file input[type="file"] {
  height: auto;
  padding: 6px 0;
  border: none;
  background: transparent;
}
.cover-hint { margin: 0; max-width: 360px; line-height: 1.4; }
td a { color: var(--accent); }
a.play-link {
  display: inline-block;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
  font-size: 12px;
}
.seg {
  display: inline-flex;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}
.seg button {
  height: 100%;
  border: none;
  border-radius: 0;
  background: #fff;
  color: var(--text);
  font-weight: 500;
  min-width: 56px;
}
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on {
  background: var(--accent);
  color: #fff;
}
.tag {
  display: inline-block;
  font-size: 12px;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
}
.tag.free {
  color: #0f766e;
  background: #ecfdf5;
  border-color: #99f6e4;
}
.tag.paid {
  color: #9a3412;
  background: #fff7ed;
  border-color: #fed7aa;
}
h2 button, h3 button { margin-left: 8px; vertical-align: middle; }
