:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #19202a;
  --muted: #657181;
  --line: #dce2e8;
  --blue: #2563eb;
  --blue-dark: #1e40af;
  --green: #16805c;
  --red: #c73737;
  --shadow: 0 18px 50px rgba(20, 30, 44, 0.13);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Pretendard, "Segoe UI", "Noto Sans KR", system-ui, sans-serif;
}

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

button {
  border: 0;
  border-radius: 8px;
  background: var(--blue);
  color: white;
  cursor: pointer;
  min-height: 40px;
  padding: 0 14px;
}

button:hover {
  background: var(--blue-dark);
}

button:disabled {
  cursor: wait;
  opacity: 0.62;
}

button.ghost {
  background: #edf2f7;
  color: var(--ink);
}

button.danger {
  background: var(--red);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  min-height: 40px;
  padding: 9px 11px;
}

textarea {
  min-height: 94px;
  resize: vertical;
}

.hidden {
  display: none !important;
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 32px;
  background: #fafafa;
}

.login-panel {
  width: min(440px, 100%);
  min-height: 319px;
  border: 0;
  border-radius: 8px;
  background: #fff;
  box-shadow: 2px 2px 16px rgba(0, 0, 0, 0.08);
  padding: 32px;
}

.login-panel h1,
.topbar h1,
.sidebar h2 {
  margin: 0;
}

.login-panel h1 {
  color: #202020;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
  margin-top: 4px;
}

.login-kicker {
  margin: 0;
  color: #707478;
  font-size: 13px;
  font-weight: 400;
  letter-spacing: -0.26px;
  line-height: 1.35;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.stack {
  display: grid;
  gap: 12px;
  margin-top: 26px;
}

label span {
  display: block;
  margin-bottom: 8px;
  color: #707478;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.26px;
  line-height: 1.2;
}

.login-panel input {
  min-height: 36px;
  border-color: #d5dae1;
  border-radius: 4px;
  color: #333;
  font-size: 13px;
  letter-spacing: -0.13px;
  padding: 9px 12px;
}

.login-panel input::placeholder {
  color: #707478;
  opacity: 1;
}

.login-panel button {
  min-height: 36px;
  border-radius: 6px;
  background: #0d5de6;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: -0.12px;
  margin-top: 6px;
}

.login-panel button:hover {
  background: #0b50c6;
}

.error {
  margin: 0;
  color: var(--red);
  min-height: 20px;
  font-size: 12px;
  line-height: 1.45;
}

.app {
  display: grid;
  grid-template-columns: 242px minmax(0, 1fr);
  min-height: 100vh;
  background:
    radial-gradient(circle at 86% 6%, rgba(255, 220, 237, 0.72), transparent 36%),
    radial-gradient(circle at 8% 86%, rgba(232, 238, 255, 0.9), transparent 42%),
    #fafafa;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid rgba(214, 222, 232, 0.76);
  background: rgba(255, 255, 255, 0.68);
  backdrop-filter: blur(22px) saturate(1.25);
  box-shadow: 18px 0 46px rgba(20, 30, 44, 0.08);
  color: #202020;
  display: flex;
  flex-direction: column;
  gap: 32px;
  padding: 40px 24px 24px;
}

.brand-kicker {
  margin: 0 0 6px;
  color: #707478;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.35;
}

.brand h2 {
  color: #0d5de6;
  font-size: 17px;
  font-weight: 800;
  line-height: 1.25;
}

.sidebar nav {
  display: grid;
  gap: 18px;
}

.nav-section-label {
  margin: 0 0 8px;
  color: #9aa1aa;
  font-size: 14px;
  font-weight: 700;
}

.nav {
  display: flex;
  min-height: 36px;
  align-items: center;
  gap: 16px;
  border-radius: 8px;
  background: transparent;
  color: #707478;
  font-size: 16px;
  font-weight: 700;
  text-align: left;
  padding: 0;
}

.nav.active,
.nav:hover {
  background: transparent;
  color: #0d5de6;
}

.nav img {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  object-fit: contain;
}

.sidebar .ghost {
  margin-top: auto;
  border: 1px solid rgba(214, 222, 232, 0.8);
  background: rgba(255, 255, 255, 0.72);
  color: #707478;
}

.workspace {
  padding: 24px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 22px;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
}

.stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.stats span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  padding: 7px 11px;
  font-size: 13px;
}

.upload-band,
.tournament-setup {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(180px, 260px);
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}

.upload-band {
  grid-template-columns: minmax(220px, 1fr) 180px minmax(240px, 1fr) 110px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 14px;
}

.file-picker {
  position: relative;
  display: grid;
  min-height: 40px;
  place-items: center;
  border: 1px dashed #aeb9c7;
  border-radius: 8px;
  background: #f8fafc;
  color: #334155;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  overflow: hidden;
}

.file-picker:hover {
  border-color: #0d5de6;
  color: #0d5de6;
}

.file-picker input {
  position: absolute;
  inset: 0;
  cursor: pointer;
  opacity: 0;
}

.upload-summary {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  margin: -4px 0 14px;
  padding: 12px 14px;
}

.upload-summary-text {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 10px;
}

.upload-summary-text strong {
  color: var(--ink);
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7edf4;
}

.progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: #0d5de6;
  transition: width 0.2s ease;
}

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

.folder-pane {
  position: sticky;
  top: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(20, 30, 44, 0.06);
  padding: 16px;
}

.pane-header h2 {
  margin: 0;
  font-size: 18px;
}

.pane-header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.folder-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 64px;
  gap: 8px;
  margin: 14px 0;
}

.folder-form button {
  min-width: 64px;
  padding: 0 10px;
}

.folder-list {
  display: grid;
  gap: 6px;
}

.folder-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  width: 100%;
  min-height: 42px;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  padding: 0 10px;
  text-align: left;
}

.folder-row:hover,
.folder-row.active {
  background: #edf4ff;
  color: #0d5de6;
}

.folder-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.folder-count {
  min-width: 24px;
  border-radius: 999px;
  background: #eef2f6;
  color: var(--muted);
  font-size: 12px;
  line-height: 22px;
  text-align: center;
}

.folder-row.active .folder-count {
  background: #dbeafe;
  color: #0d5de6;
}

.folder-delete {
  border-radius: 999px;
  color: #c73737;
  font-size: 12px;
  padding: 4px 6px;
}

.folder-delete:hover {
  background: #fee2e2;
}

.inline {
  display: flex;
  gap: 8px;
}

.inline button {
  width: 110px;
  flex: 0 0 auto;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
}

.image-card,
.note,
.winner-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(20, 30, 44, 0.07);
  overflow: hidden;
}

.image-preview-trigger {
  display: block;
  width: 100%;
  min-height: 0;
  border-radius: 0;
  background: transparent;
  padding: 0;
}

.image-preview-trigger:hover {
  background: transparent;
}

.image-card img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: #e8edf2;
}

.image-meta {
  display: grid;
  gap: 9px;
  padding: 12px;
}

.card-actions {
  display: grid;
  grid-template-columns: minmax(82px, 0.75fr) minmax(120px, 1.25fr);
  gap: 8px;
}

.download-image {
  background: #0d5de6;
}

.download-image:hover {
  background: #0b50c6;
}

.note-editor {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 180px 100px;
  gap: 10px;
  align-items: start;
  margin-bottom: 16px;
}

.note-editor textarea {
  grid-column: 1 / -1;
}

.notes-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.note {
  padding: 16px;
}

.note header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.note h3 {
  margin: 0;
  font-size: 17px;
}

.note pre {
  margin: 0;
  color: #313a46;
  white-space: pre-wrap;
  word-break: break-word;
}

.badge {
  border-radius: 999px;
  background: #e8f4ef;
  color: var(--green);
  padding: 5px 8px;
  font-size: 12px;
  height: fit-content;
}

.match {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.choice {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 0;
  color: var(--ink);
  overflow: hidden;
  text-align: left;
}

.choice:hover {
  background: #f6f9fc;
}

.choice img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  background: #111820;
  display: block;
}

.choice strong {
  display: block;
  padding: 12px;
}

.winner-panel {
  display: grid;
  grid-template-columns: minmax(260px, 420px) 1fr;
  gap: 18px;
  padding: 16px;
}

.winner-panel img {
  width: 100%;
  border-radius: 8px;
}

.empty {
  border: 1px dashed #b9c4d0;
  border-radius: 8px;
  color: var(--muted);
  padding: 28px;
  text-align: center;
  background: rgba(255, 255, 255, 0.65);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.34);
}

.modal-panel {
  width: min(380px, 100%);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 60px rgba(15, 23, 42, 0.22);
  padding: 22px;
}

.modal-type {
  margin: 0 0 8px;
  color: #0d5de6;
  font-size: 12px;
  font-weight: 700;
}

.modal-panel h2 {
  margin: 0;
  color: #202020;
  font-size: 20px;
}

.modal-panel p {
  color: var(--muted);
  line-height: 1.55;
}

.modal-panel button {
  width: 100%;
  margin-top: 8px;
}

.image-preview-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.72);
}

.image-preview-panel {
  position: relative;
  width: min(1080px, 100%);
  max-height: min(860px, calc(100vh - 48px));
  overflow: hidden;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.35);
}

.image-preview-panel img {
  width: 100%;
  max-height: calc(100vh - 48px);
  object-fit: contain;
  background: #101319;
}

.preview-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 1;
  display: grid;
  width: 38px;
  height: 38px;
  min-height: 38px;
  place-items: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: #202020;
  font-size: 24px;
  padding: 0;
}

.preview-download {
  position: absolute;
  right: 14px;
  bottom: 14px;
  min-height: 38px;
  border-radius: 999px;
  background: rgba(13, 93, 230, 0.94);
  box-shadow: 0 12px 32px rgba(13, 93, 230, 0.26);
  font-size: 13px;
  font-weight: 800;
}

@media (max-width: 820px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .sidebar nav {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .topbar,
  .upload-band,
  .note-editor,
  .winner-panel,
  .match {
    grid-template-columns: 1fr;
  }

  .upload-summary-text {
    display: grid;
  }

  .topbar {
    display: grid;
  }

  .image-preview-panel img {
    max-height: calc(100vh - 32px);
  }

  .library-layout {
    grid-template-columns: 1fr;
  }

  .folder-pane {
    position: static;
  }
}

@media (max-width: 560px) {
  .login-shell {
    align-items: center;
    padding: 20px;
  }

  .login-panel {
    min-height: auto;
    padding: 28px 24px;
  }

  .login-panel h1 {
    font-size: 22px;
  }
}

/* Image library redesign */
.workspace {
  background: transparent;
  padding: 58px 32px;
}

.workspace-inner {
  max-width: 1120px;
  margin: 0 auto;
}

.topbar {
  margin-bottom: 28px;
}

.topbar h1 {
  color: #202020;
  font-size: 24px;
  font-weight: 800;
  line-height: 1.2;
}

.topbar p {
  color: #707478;
  font-size: 13px;
}

.library-layout {
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 20px;
}

.folder-pane {
  height: min(732px, calc(100vh - 96px));
  border-radius: 8px;
  box-shadow: none;
  overflow: hidden;
}

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

.pane-header h2,
.upload-panel h2 {
  margin: 0;
  color: #202020;
  font-size: 16px;
  font-weight: 800;
}

.folder-add-toggle {
  min-height: 30px;
  border: 1px solid #0d5de6;
  border-radius: 4px;
  background: #fff;
  color: #0d5de6;
  font-size: 12px;
  font-weight: 700;
  padding: 0 10px;
}

.folder-add-toggle:hover {
  background: #eef5ff;
}

.folder-search {
  position: relative;
  display: block;
  margin: 14px 0 12px;
}

.folder-search input {
  min-height: 36px;
  border-radius: 4px;
  padding-right: 38px;
  font-size: 13px;
}

.folder-search span {
  position: absolute;
  right: 12px;
  top: 50%;
  color: #202020;
  font-size: 24px;
  line-height: 1;
  transform: translateY(-52%);
}

.folder-list {
  align-content: start;
  gap: 2px;
  max-height: calc(100% - 92px);
  overflow-y: auto;
  padding-right: 4px;
}

.folder-row {
  min-height: 40px;
  border-radius: 0;
  padding: 0 8px;
  font-size: 13px;
}

.folder-delete {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border: 1px solid #d5dae1;
  border-radius: 4px;
  color: #707478;
  font-size: 13px;
  padding: 0;
}

.folder-delete:hover {
  background: #fee2e2;
  color: #c73737;
}

.library-content {
  min-width: 0;
}

.upload-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  margin-bottom: 16px;
  padding: 16px;
}

.upload-panel h2 {
  margin-bottom: 16px;
}

.upload-band {
  grid-template-columns: 1fr;
  gap: 16px;
  border: 0;
  border-radius: 0;
  background: transparent;
  margin: 0;
  padding: 0;
}

.file-picker {
  min-height: 52px;
  border: 1px solid #d5dae1;
  border-radius: 4px;
  background: #fff;
  color: #0d5de6;
}

.upload-band select,
.upload-band input:not([type="file"]) {
  min-height: 36px;
  border-radius: 4px;
  font-size: 13px;
}

.upload-band button {
  min-height: 36px;
  border-radius: 6px;
  background: #0d5de6;
  font-size: 12px;
  font-weight: 700;
}

.upload-summary {
  margin: 16px 0 0;
  border-width: 1px 0 0;
  border-radius: 0;
  padding: 14px 0 0;
}

.image-grid {
  grid-template-columns: repeat(auto-fill, minmax(164px, 164px));
  gap: 10px;
  align-items: start;
}

.image-card,
.note,
.winner-panel {
  border-radius: 4px;
  box-shadow: none;
}

.image-card img {
  height: 164px;
  aspect-ratio: auto;
}

.image-meta {
  gap: 8px;
  padding: 8px;
}

.image-meta input,
.image-meta select,
.image-meta textarea {
  min-height: 30px;
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 12px;
}

.card-actions {
  grid-template-columns: minmax(58px, 0.72fr) minmax(86px, 1.28fr);
  gap: 6px;
}

.card-actions button {
  min-height: 30px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
  padding: 0 8px;
}

@media (max-width: 820px) {
  .workspace {
    padding: 28px 16px;
  }

  .library-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
  }

  .library-content,
  .upload-panel {
    width: 100%;
  }

  .folder-pane {
    height: auto;
    width: 100%;
  }

  .folder-list {
    max-height: 320px;
  }

  .image-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }

  .image-card img {
    height: auto;
    aspect-ratio: 1 / 1;
  }
}

/* Icon refinements */
.file-picker span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.file-picker img {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
}

.folder-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.folder-label {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 6px;
}

.folder-label .folder-name {
  flex: 0 1 auto;
}

.folder-label .folder-count {
  flex: 0 0 auto;
}

.folder-delete {
  border: 0;
}

.folder-delete img {
  display: block;
  width: 16px;
  height: 16px;
}

/* Tournament redesign */
.tournament-panel {
  min-width: 0;
}

.tournament-setup-card {
  width: min(720px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 60px rgba(20, 30, 44, 0.08);
  margin: 38px auto 0;
  padding: 28px;
}

.tournament-setup-card h2,
.loss-toolbar h2,
.table-head h2 {
  margin: 0;
  color: #202020;
  font-size: 24px;
  font-weight: 800;
}

.setup-copy,
.loss-toolbar p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.setup-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 22px 0 14px;
}

.cleanup-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #313a46;
  padding: 12px;
}

.cleanup-toggle input {
  width: 16px;
  height: 16px;
}

.setup-meta {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 14px 0;
}

.setup-meta span {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fafafa;
  color: #a13a61;
  font-weight: 800;
  padding: 12px;
  text-align: center;
}

.tournament-setup-card > button {
  width: 100%;
  min-height: 42px;
  border-radius: 6px;
  background: #0d5de6;
  font-weight: 800;
}

.match {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 28px;
}

.match-progress {
  grid-column: 1 / -1;
  text-align: center;
}

.match-progress span {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  border-radius: 999px;
  background: #eef2ff;
  color: #5b5f75;
  font-weight: 800;
  padding: 0 18px;
}

.match-progress strong {
  display: block;
  margin-top: 8px;
  color: #202020;
  font-size: 14px;
}

.match-progress p {
  margin: 8px 0 0;
  color: #202020;
  font-size: 24px;
  font-weight: 800;
}

.choice {
  border-radius: 14px;
  background: #111319;
  box-shadow: 0 16px 48px rgba(20, 30, 44, 0.12);
}

.choice img {
  aspect-ratio: 4 / 3;
  padding: 18px;
  object-fit: contain;
}

.choice strong,
.choice span {
  display: block;
  background: #fff;
}

.choice strong {
  overflow: hidden;
  color: #202020;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 14px 16px 4px;
}

.choice span {
  color: var(--muted);
  font-size: 12px;
  padding: 0 16px 14px;
}

.winner-panel {
  align-items: center;
  border-radius: 14px;
  box-shadow: 0 16px 48px rgba(20, 30, 44, 0.12);
}

.winner-panel button {
  margin-top: 18px;
}

.ranking-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.ranking-card,
.ranking-table-wrap,
.loss-toolbar,
.loss-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 10px 32px rgba(20, 30, 44, 0.06);
}

.ranking-card {
  position: relative;
  overflow: hidden;
}

.ranking-card img,
.loss-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #111319;
}

.rank-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: #a13a61;
  font-weight: 800;
  padding: 7px 10px;
}

.ranking-card div,
.loss-card-body {
  padding: 14px;
}

.ranking-card h3,
.loss-card h3,
.ranking-row h3 {
  overflow: hidden;
  margin: 0;
  color: #202020;
  font-size: 15px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ranking-card p,
.ranking-row p {
  margin: 6px 0;
  color: var(--muted);
  font-size: 12px;
}

.ranking-card div > span,
.loss-metrics span {
  display: inline-flex;
  border-radius: 999px;
  background: #ffe4ef;
  color: #a13a61;
  font-size: 12px;
  font-weight: 800;
  padding: 5px 8px;
}

.ranking-table-wrap {
  margin-top: 20px;
  padding: 16px;
}

.table-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.table-head span {
  color: var(--muted);
  font-size: 13px;
}

.ranking-table {
  display: grid;
}

.ranking-row {
  display: grid;
  grid-template-columns: 58px 46px minmax(0, 1fr) 70px 70px 70px 70px;
  gap: 10px;
  align-items: center;
  border-top: 1px solid var(--line);
  padding: 10px 0;
}

.ranking-row img {
  width: 46px;
  height: 46px;
  border-radius: 8px;
  object-fit: cover;
}

.ranking-row > strong,
.ranking-row > span {
  color: #313a46;
  font-size: 13px;
  font-weight: 800;
}

.loss-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  padding: 18px;
}

.loss-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}

.loss-card {
  overflow: hidden;
}

.loss-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 10px 0 12px;
}

.loss-card button {
  width: 100%;
  min-height: 34px;
  border-radius: 4px;
}

/* Prompt library redesign */
.notes-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.note-pane,
.note-editor-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: none;
}

.note-pane {
  position: sticky;
  top: 24px;
  height: min(732px, calc(100vh - 96px));
  overflow: hidden;
  padding: 16px;
}

.note-filters {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  margin: 20px 0 16px;
}

.note-filter {
  position: relative;
  min-height: 36px;
  border-radius: 0;
  background: transparent;
  color: #707478;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.2;
  padding: 0 2px;
}

.note-filter.active {
  color: #202020;
}

.note-filter.active::after {
  position: absolute;
  right: 8px;
  bottom: -7px;
  left: 8px;
  height: 4px;
  border-radius: 999px;
  background: #202020;
  content: "";
}

.note-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  align-items: center;
  min-height: 36px;
  border: 1px solid #d5dae1;
  border-radius: 4px;
  margin: 20px 0 12px;
  background: #fff;
}

.note-search input {
  min-height: 34px;
  border: 0;
  background: transparent;
  padding: 0 10px;
}

.note-search span {
  color: #202020;
  font-size: 24px;
  line-height: 1;
  text-align: center;
}

.notes-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  max-height: calc(100% - 138px);
  overflow: auto;
  padding-right: 4px;
}

.note-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  border-radius: 6px;
  background: transparent;
  padding: 12px 10px;
}

.note-row:hover {
  background: #edf4ff;
}

.note-row-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.note-row h3 {
  overflow: hidden;
  margin: 0;
  color: #202020;
  font-size: 14px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-row p {
  display: -webkit-box;
  overflow: hidden;
  margin: 7px 0 0;
  color: #707478;
  font-size: 12px;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.note-row .badge {
  flex: 0 0 auto;
  border-radius: 999px;
  background: #eef2ff;
  color: #0d5de6;
  font-size: 11px;
  line-height: 20px;
  padding: 0 8px;
}

.note-row-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.note-row-actions button {
  min-height: 30px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
  padding: 0 8px;
}

.note-row-actions .delete-note {
  background: #c52f2f;
}

.note-content {
  min-width: 0;
}

.note-editor-panel {
  padding: 16px;
}

.note-editor-panel h2 {
  margin: 0 0 16px;
  color: #202020;
  font-size: 16px;
  font-weight: 800;
}

.note-editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: 12px;
  margin: 0;
}

.note-editor textarea {
  grid-column: 1 / -1;
  min-height: 360px;
  resize: vertical;
}

.note-editor button {
  grid-column: 1 / -1;
  min-height: 38px;
  border-radius: 6px;
  background: #0d5de6;
  font-size: 12px;
  font-weight: 700;
}

@media (max-width: 820px) {
  .notes-layout {
    grid-template-columns: 1fr;
  }

  .note-pane {
    position: static;
    height: auto;
  }

  .notes-list {
    max-height: 320px;
  }

  .note-filter {
    font-size: 13px;
  }

  .note-editor {
    grid-template-columns: 1fr;
  }

  .note-editor textarea {
    min-height: 260px;
  }

  .setup-grid,
  .setup-meta,
  .match,
  .ranking-grid {
    grid-template-columns: 1fr;
  }

  .tournament-setup-card {
    margin-top: 0;
    padding: 20px;
  }

  .ranking-row {
    grid-template-columns: 48px 42px minmax(0, 1fr);
  }

  .ranking-row > span {
    display: none;
  }
}
