/* CPE OJ design system — dual theme.
   Light (default): "practice dashboard" — blue-gray canvas, white cards, gold reserved for honors.
   Dark ([data-theme="dark"]): "midnight arena" — navy canvas, champagne gold as the accent.
   All component colors must come from tokens; no hardcoded hex below the token layer. */
:root {
  --oj-bg: #f4f6f9;
  --oj-panel: #ffffff;
  --oj-panel-muted: #f7f9fc;
  --oj-border: #e4e8ef;
  --oj-border-strong: #c9d2df;
  --oj-border-faint: #eef1f6;
  --oj-text: #1e2430;
  --oj-heading: #171c26;
  --oj-muted: #64708a;
  --oj-text-soft: #3f4a5f;
  --oj-primary: #526390;
  --oj-primary-dark: #3d4c74;
  --oj-primary-contrast: #ffffff;
  --oj-primary-soft: #eff2f8;
  --oj-accent: #526390;
  --oj-accent-dark: #3d4c74;
  --oj-accent-soft: #eff2f8;
  --oj-link: #3d4c74;
  --oj-link-hover: #2c3a5e;
  --oj-gold: #c9a45c;
  --oj-gold-deep: #b08d4f;
  --oj-gold-soft: #f7efdc;
  --oj-success: #1f7a4d;
  --oj-success-soft: #e4f2e9;
  --oj-warning: #9a6a15;
  --oj-warning-soft: #fcf1dc;
  --oj-danger: #b04a45;
  --oj-danger-soft: #fbe7e6;
  --oj-info: #2c6e9e;
  --oj-info-soft: #e6f1fa;
  --oj-purple: #6b4e9b;
  --oj-purple-soft: #f0eaf7;
  --oj-hover-bg: #f1f4f8;
  --oj-input-bg: #ffffff;
  --oj-input-border: #d6dde7;
  --oj-navbar-bg: rgba(255, 255, 255, 0.94);
  --oj-code-bg: #101828;
  --oj-code-border: #1d2939;
  --oj-code-text: #e4e7ec;
  --oj-medal-gold-bg: #c9a45c;
  --oj-medal-gold-text: #453410;
  --oj-medal-silver-bg: #d5dae1;
  --oj-medal-silver-text: #3d4652;
  --oj-medal-bronze-bg: #d2a585;
  --oj-medal-bronze-text: #4a2f1b;
  --oj-radius: 8px;
  --oj-control-radius: 8px;
  --oj-radius-lg: 12px;
  --oj-shadow-sm: 0 1px 2px rgba(23, 32, 51, 0.05);
  --oj-shadow-md: 0 10px 28px rgba(23, 32, 51, 0.12);
  --oj-focus: 0 0 0 3px rgba(82, 99, 144, 0.25);
  --oj-font-serif: Georgia, "Songti TC", "Noto Serif TC", "PMingLiU", serif;
  --oj-font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

[data-theme="dark"] {
  --oj-bg: #161d2e;
  --oj-panel: #1f2940;
  --oj-panel-muted: #1a2338;
  --oj-border: #2e3a54;
  --oj-border-strong: #3d4a68;
  --oj-border-faint: #263149;
  --oj-text: #e8eaf0;
  --oj-heading: #f3f5f9;
  --oj-muted: #9aa5bc;
  --oj-text-soft: #c3cbdb;
  --oj-primary: #d4b06a;
  --oj-primary-dark: #e4cd9c;
  --oj-primary-contrast: #241b07;
  --oj-accent: #d4b06a;
  --oj-accent-dark: #e4cd9c;
  --oj-accent-soft: rgba(212, 176, 106, 0.14);
  --oj-primary-soft: rgba(212, 176, 106, 0.14);
  --oj-link: #d4b06a;
  --oj-link-hover: #e4cd9c;
  --oj-gold: #d4b06a;
  --oj-gold-deep: #d4b06a;
  --oj-gold-soft: rgba(212, 176, 106, 0.14);
  --oj-success: #4cc38a;
  --oj-success-soft: rgba(76, 195, 138, 0.15);
  --oj-warning: #e0a34e;
  --oj-warning-soft: rgba(224, 163, 78, 0.15);
  --oj-danger: #e5646e;
  --oj-danger-soft: rgba(229, 100, 110, 0.15);
  --oj-info: #6fb6e8;
  --oj-info-soft: rgba(111, 182, 232, 0.15);
  --oj-purple: #b49ae8;
  --oj-purple-soft: rgba(160, 130, 220, 0.16);
  --oj-hover-bg: rgba(255, 255, 255, 0.04);
  --oj-input-bg: #182135;
  --oj-input-border: #3d4a68;
  --oj-navbar-bg: rgba(22, 29, 46, 0.94);
  --oj-code-bg: #101828;
  --oj-code-border: #263149;
  --oj-code-text: #e4e7ec;
  --oj-medal-gold-bg: #d4b06a;
  --oj-medal-gold-text: #241b07;
  --oj-medal-silver-bg: #3a465f;
  --oj-medal-silver-text: #c6cedd;
  --oj-medal-bronze-bg: #4a3b2b;
  --oj-medal-bronze-text: #ddb88f;
  --oj-shadow-sm: none;
  --oj-shadow-md: 0 12px 30px rgba(0, 0, 0, 0.45);
  --oj-focus: 0 0 0 3px rgba(212, 176, 106, 0.3);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  background: var(--oj-bg);
  color: var(--oj-text);
  font-family: Inter, "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  min-height: 100%;
  overflow-x: hidden;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  color: var(--oj-heading);
  letter-spacing: -0.01em;
}

a {
  color: var(--oj-link);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a:hover {
  color: var(--oj-link-hover);
}

:focus-visible {
  border-radius: 4px;
  outline: 2px solid var(--oj-primary);
  outline-offset: 2px;
}

.text-muted {
  color: var(--oj-muted) !important;
}

.min-w-0 {
  min-width: 0 !important;
}

.oj-page {
  max-width: 1240px;
}

.oj-main {
  padding-bottom: 48px;
  padding-top: 30px;
}

/* Brand wordmark: serif gold, echoes the logo lettering. */
.oj-wordmark {
  color: var(--oj-gold-deep);
  font-family: var(--oj-font-serif);
  font-weight: 500;
  letter-spacing: 0.01em;
}

.oj-wordmark .oj-brand-dot {
  color: var(--oj-gold);
}

/* Theme-paired logo assets: day (bronze on light) / night (champagne on dark).
   Type-qualified so they outrank page-level sizing rules like .oj-home-logo. */
img.oj-logo-night {
  display: none;
}

[data-theme="dark"] img.oj-logo-day {
  display: none;
}

[data-theme="dark"] img.oj-logo-night {
  display: block;
}

/* Navigation */
.oj-navbar {
  backdrop-filter: blur(8px);
  background: var(--oj-navbar-bg);
  border-bottom: 1px solid var(--oj-border);
  min-height: 64px;
  position: sticky;
  top: 0;
  z-index: 1030;
}

.navbar-brand {
  align-items: center;
  color: var(--oj-gold-deep);
  display: inline-flex;
  font-size: 20px;
  gap: 0;
}

.navbar-brand:hover {
  color: var(--oj-gold);
}

.oj-brand-dot {
  color: var(--oj-gold);
}

.oj-primary-nav {
  gap: 6px;
  margin-left: 20px;
}

.nav-link {
  border: 0;
  border-radius: 999px;
  color: var(--oj-muted);
  font-size: 14px;
  font-weight: 500;
  padding: 8px 14px !important;
}

.nav-link:hover,
.nav-link:focus {
  background: var(--oj-hover-bg);
  color: var(--oj-link);
}

.nav-link.active,
.nav-link[aria-current="page"] {
  background: var(--oj-primary-soft);
  color: var(--oj-link);
  font-weight: 600;
}

.oj-account-nav {
  align-items: center;
  gap: 8px;
}

.oj-nav-cta {
  align-items: center;
  display: inline-flex;
  min-height: 44px !important;
  padding: 8px 18px;
}

/* Theme toggle */
.oj-theme-toggle {
  align-items: center;
  background: transparent;
  border: 1px solid var(--oj-border);
  border-radius: 999px;
  color: var(--oj-muted);
  cursor: pointer;
  display: inline-flex;
  height: 38px;
  justify-content: center;
  padding: 0;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
  width: 38px;
}

.oj-theme-toggle:hover {
  background: var(--oj-hover-bg);
  border-color: var(--oj-border-strong);
  color: var(--oj-text);
}

.oj-theme-toggle svg {
  display: block;
  height: 17px;
  width: 17px;
}

.oj-theme-toggle .oj-theme-icon-moon {
  display: block;
}

.oj-theme-toggle .oj-theme-icon-sun {
  display: none;
}

[data-theme="dark"] .oj-theme-toggle .oj-theme-icon-moon {
  display: none;
}

[data-theme="dark"] .oj-theme-toggle .oj-theme-icon-sun {
  display: block;
}

[data-theme="dark"] .oj-theme-toggle {
  color: var(--oj-gold);
}

.oj-user-menu-toggle {
  align-items: center;
  background: transparent;
  border: 0;
  display: flex;
  gap: 9px;
  max-width: 240px;
  text-decoration: none;
}

.oj-user-menu-wrap {
  align-items: center;
  display: flex;
}

.oj-user-menu-dropdown-toggle {
  border-left: 1px solid var(--oj-border) !important;
  border-radius: 0 999px 999px 0;
  margin-left: 1px;
  padding-left: 8px !important;
  padding-right: 8px !important;
}

.oj-avatar {
  align-items: center;
  background: var(--oj-primary-soft);
  border: 1px solid var(--oj-border);
  border-radius: 50%;
  color: var(--oj-link);
  display: inline-flex;
  flex: 0 0 auto;
  font-weight: 600;
  justify-content: center;
  line-height: 1;
  overflow: hidden;
  position: relative;
  text-transform: uppercase;
}

.oj-avatar img {
  display: block;
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.oj-avatar-sm {
  font-size: 12px;
  height: 30px;
  width: 30px;
}

.oj-avatar-md {
  font-size: 18px;
  height: 44px;
  width: 44px;
}

.oj-avatar-lg {
  font-size: 28px;
  height: 72px;
  width: 72px;
}

.oj-avatar-xl {
  font-size: 42px;
  height: 112px;
  width: 112px;
}

.oj-avatar-link {
  border-radius: 50%;
  display: inline-flex;
  flex: 0 0 auto;
  text-decoration: none;
}

.oj-discussion-author {
  align-items: center;
  display: flex;
  gap: 8px;
  min-width: 0;
}

.oj-discussion-author-name {
  color: var(--oj-text);
  font-weight: 600;
  text-decoration: none;
}

.oj-user-menu-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.oj-user-menu {
  background: var(--oj-panel);
  border: 1px solid var(--oj-border);
  border-radius: var(--oj-radius);
  box-shadow: var(--oj-shadow-md);
  min-width: 190px;
  padding: 7px;
}

.oj-user-menu .dropdown-item {
  border-radius: 6px;
  color: var(--oj-text-soft);
  font-size: 14px;
  font-weight: 500;
  padding: 9px 11px;
}

.oj-user-menu .dropdown-item:hover,
.oj-user-menu .dropdown-item:focus,
.oj-user-menu .dropdown-item.active,
.oj-user-menu .dropdown-item[aria-current="page"] {
  background: var(--oj-primary-soft);
  color: var(--oj-link);
}

/* Surfaces and headings */
.oj-panel {
  background: var(--oj-panel);
  border: 1px solid var(--oj-border);
  border-radius: var(--oj-radius);
  box-shadow: var(--oj-shadow-sm);
  min-width: 0;
}

.oj-panel-interactive {
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.oj-panel-interactive:hover {
  border-color: var(--oj-border-strong);
  box-shadow: var(--oj-shadow-md);
  transform: translateY(-1px);
}

.oj-page-heading {
  align-items: flex-end;
  display: flex;
  gap: 20px;
  justify-content: space-between;
  margin-bottom: 20px;
}

.oj-responsive-heading {
  align-items: flex-end;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  min-width: 0;
}

.oj-responsive-heading > :first-child {
  min-width: 0;
}

.oj-heading-actions {
  align-items: center;
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  min-width: 0;
}

.oj-page-heading h1 {
  font-size: clamp(24px, 3vw, 30px);
  font-weight: 700 !important;
  line-height: 1.2;
  margin-bottom: 5px !important;
}

.oj-page-heading-subtitle {
  color: var(--oj-muted);
  max-width: 720px;
}

.oj-section-heading {
  align-items: flex-end;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 14px;
}

.oj-section-heading h2 {
  margin-bottom: 3px;
}

.oj-section-title {
  color: var(--oj-heading);
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 12px;
}

.oj-eyebrow {
  color: var(--oj-gold-deep);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.oj-empty-state {
  color: var(--oj-muted);
  padding: 38px 24px;
  text-align: center;
}

.oj-empty-state .fw-semibold {
  color: var(--oj-heading);
  font-size: 16px;
}

/* Buttons and forms */
.btn {
  align-items: center;
  border-radius: var(--oj-control-radius);
  display: inline-flex;
  font-weight: 500;
  justify-content: center;
  min-height: 44px;
}

.btn-sm {
  min-height: 44px;
}

.btn-primary {
  --bs-btn-bg: var(--oj-primary);
  --bs-btn-border-color: var(--oj-primary);
  --bs-btn-hover-bg: var(--oj-primary-dark);
  --bs-btn-hover-border-color: var(--oj-primary-dark);
  --bs-btn-active-bg: var(--oj-primary-dark);
  --bs-btn-active-border-color: var(--oj-primary-dark);
  --bs-btn-color: var(--oj-primary-contrast);
  --bs-btn-hover-color: var(--oj-primary-contrast);
  --bs-btn-active-color: var(--oj-primary-contrast);
  box-shadow: none;
}

.btn-outline-secondary {
  --bs-btn-color: var(--oj-text-soft);
  --bs-btn-bg: var(--oj-panel);
  --bs-btn-border-color: var(--oj-input-border);
  --bs-btn-hover-bg: var(--oj-hover-bg);
  --bs-btn-hover-border-color: var(--oj-border-strong);
  --bs-btn-hover-color: var(--oj-heading);
  --bs-btn-active-bg: var(--oj-hover-bg);
  --bs-btn-active-border-color: var(--oj-border-strong);
  --bs-btn-active-color: var(--oj-heading);
}

.btn-outline-danger {
  --bs-btn-color: var(--oj-danger);
  --bs-btn-border-color: var(--oj-danger);
  --bs-btn-hover-bg: var(--oj-danger);
  --bs-btn-hover-border-color: var(--oj-danger);
}

.form-label {
  color: var(--oj-text-soft);
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 7px;
}

.form-text {
  color: var(--oj-muted);
  font-size: 12px;
  line-height: 1.5;
  margin-top: 7px;
}

.form-text ul {
  margin: 0;
  padding-left: 18px;
}

input[type="text"],
input:not([type]),
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="url"],
textarea,
select {
  background: var(--oj-input-bg);
  border: 1px solid var(--oj-input-border);
  border-radius: var(--oj-control-radius);
  color: var(--oj-text);
  min-height: 44px;
  padding: 10px 12px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  width: 100%;
}

textarea {
  min-height: 120px;
}

input[type="text"]:focus,
input:not([type]):focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="search"]:focus,
input[type="url"]:focus,
textarea:focus,
select:focus {
  border-color: var(--oj-primary);
  box-shadow: var(--oj-focus);
  outline: 0;
}

input::placeholder,
textarea::placeholder {
  color: var(--oj-muted);
  opacity: 0.8;
}

.form-check {
  align-items: flex-start;
  display: flex;
  gap: 9px;
  margin-bottom: 14px;
  min-height: 24px;
  padding-left: 0;
}

.form-check input[type="checkbox"] {
  flex: 0 0 auto;
  height: 17px;
  margin: 3px 0 0;
  min-height: 0;
  width: 17px;
}

.form-check .form-check-label {
  color: var(--oj-text-soft);
  font-size: 13px;
  font-weight: 500;
  margin: 0;
}

.oj-form-grid {
  display: grid;
  gap: 17px;
}

.oj-form-actions {
  align-items: center;
  border-top: 1px solid var(--oj-border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 6px;
  padding-top: 18px;
}

.oj-combobox {
  position: relative;
}

.oj-combobox-menu {
  background: var(--oj-panel);
  border: 1px solid var(--oj-border-strong);
  border-radius: var(--oj-control-radius);
  box-shadow: var(--oj-shadow-md);
  display: none;
  left: 0;
  max-height: 240px;
  overflow-y: auto;
  position: absolute;
  right: 0;
  top: calc(100% + 5px);
  z-index: 1060;
}

.oj-combobox.open .oj-combobox-menu {
  display: block;
}

.oj-combobox-option {
  cursor: pointer;
  padding: 10px 12px;
}

.oj-combobox-option:hover,
.oj-combobox-option.active {
  background: var(--oj-primary-soft);
  color: var(--oj-link);
}

.oj-combobox-empty {
  color: var(--oj-muted);
  padding: 10px 12px;
}

.alert {
  border-radius: var(--oj-radius);
}

.alert-error {
  background-color: var(--oj-danger-soft);
  border-color: var(--oj-danger);
  color: var(--oj-danger);
}

/* Authentication */
.oj-auth-shell {
  align-items: start;
  display: grid;
  justify-items: center;
  min-height: calc(100vh - 150px);
  padding: 30px 0;
}

.oj-auth-card {
  background: var(--oj-panel);
  border: 1px solid var(--oj-border);
  border-radius: var(--oj-radius-lg);
  box-shadow: var(--oj-shadow-sm);
  padding: 32px 34px;
  width: min(480px, 100%);
}

.oj-auth-title {
  color: var(--oj-heading);
  font-size: 26px;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 8px;
}

.oj-auth-subtitle {
  color: var(--oj-muted);
  margin-bottom: 24px;
}

.oj-auth-card .mb-3 {
  margin-bottom: 16px !important;
}

/* Badges: tinted pills */
.oj-badge {
  align-items: center;
  background: var(--oj-panel-muted);
  border: 0;
  border-radius: 999px;
  color: var(--oj-text-soft);
  display: inline-flex;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  padding: 4px 10px;
  white-space: nowrap;
}

.oj-badge-success,
.oj-badge-easy,
.oj-badge-difficulty-easy {
  background: var(--oj-success-soft);
  color: var(--oj-success);
}

.oj-badge-warning,
.oj-badge-difficulty-medium {
  background: var(--oj-warning-soft);
  color: var(--oj-warning);
}

.oj-badge-danger,
.oj-badge-difficulty-hard {
  background: var(--oj-danger-soft);
  color: var(--oj-danger);
}

.oj-badge-info {
  background: var(--oj-info-soft);
  color: var(--oj-info);
}

.oj-badge-neutral {
  background: var(--oj-panel-muted);
  color: var(--oj-text-soft);
}

.oj-badge-gold {
  background: var(--oj-gold-soft);
  color: var(--oj-gold-deep);
}

.oj-badge-button {
  border: 0;
  cursor: pointer;
  min-height: 44px;
}

.oj-badge-button:hover,
.oj-badge-button:focus {
  filter: brightness(0.96);
}

/* Leaderboard medals: the honor moment reserved for gold */
.oj-medal {
  align-items: center;
  border-radius: 50%;
  display: inline-flex;
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 600;
  height: 26px;
  justify-content: center;
  line-height: 1;
  width: 26px;
}

.oj-medal-gold {
  background: var(--oj-medal-gold-bg);
  color: var(--oj-medal-gold-text);
}

.oj-medal-silver {
  background: var(--oj-medal-silver-bg);
  color: var(--oj-medal-silver-text);
}

.oj-medal-bronze {
  background: var(--oj-medal-bronze-bg);
  color: var(--oj-medal-bronze-text);
}

/* Statistics */
.oj-stat-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.oj-stat {
  background: var(--oj-panel);
  min-height: 104px;
  padding: 18px;
}

.oj-stat-label {
  color: var(--oj-muted);
  font-size: 13px;
  font-weight: 500;
}

.oj-stat-value {
  color: var(--oj-heading);
  display: block;
  font-size: 27px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin-top: 7px;
}

.oj-metric-strip {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.oj-metric-strip-compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.oj-metric {
  background: var(--oj-panel);
  border: 1px solid var(--oj-border);
  border-radius: var(--oj-radius);
  box-shadow: var(--oj-shadow-sm);
  min-width: 0;
  padding: 16px 18px;
}

.oj-stat-value-text {
  font-size: 16px;
  line-height: 1.4;
  margin-top: 12px;
  overflow-wrap: anywhere;
}

/* Tables */
.oj-table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--oj-text);
  --bs-table-hover-bg: var(--oj-hover-bg);
  --bs-table-hover-color: var(--oj-text);
  color: var(--oj-text);
  font-size: 14px;
}

.oj-table thead th {
  background: var(--oj-panel-muted);
  border-bottom: 1px solid var(--oj-border);
  color: var(--oj-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  padding: 11px 16px;
  text-transform: uppercase;
  vertical-align: middle;
}

.oj-table tbody td {
  border-color: var(--oj-border-faint);
  padding: 13px 16px;
  vertical-align: middle;
}

.oj-table tbody tr:hover > td {
  background: var(--oj-hover-bg);
}

.oj-table td {
  overflow-wrap: anywhere;
}

.oj-front-table .oj-table-align-center {
  text-align: center;
}

.oj-table-scroll {
  max-height: 560px;
  overflow: auto;
}

.oj-table-scroll-sm {
  max-height: 320px;
}

.oj-table-scroll-lg {
  max-height: 680px;
}

.oj-table-scroll .oj-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
}

.oj-table-fixed {
  table-layout: fixed;
}

.oj-table-roomy {
  table-layout: auto;
}

.oj-cell-primary,
.oj-cell-secondary {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
}

.oj-cell-primary {
  color: var(--oj-heading);
  font-weight: 600;
}

.oj-cell-secondary {
  color: var(--oj-muted);
  font-size: 12px;
  margin-top: 2px;
}

.oj-line-clamp-2,
.oj-line-clamp-3 {
  -webkit-box-orient: vertical;
  display: -webkit-box !important;
  overflow: hidden;
}

.oj-line-clamp-2 {
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

.oj-line-clamp-3 {
  -webkit-line-clamp: 3;
  line-clamp: 3;
}

.oj-table-actions {
  max-width: 100%;
  white-space: normal;
}

td.oj-table-actions {
  min-width: 164px;
  padding-right: 18px !important;
  text-align: right;
  width: 1%;
}

.oj-table-actions-wide {
  min-width: 240px;
  width: 1%;
}

.oj-table-actions > .btn,
.oj-table-actions > form {
  margin: 4px 0 4px 7px;
  vertical-align: middle;
}

.oj-table-actions form {
  display: inline-flex;
}

.oj-table-card-label {
  color: var(--oj-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.oj-tag-list {
  align-items: flex-start;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.oj-table .oj-tag-list {
  max-height: 64px;
  max-width: 290px;
  overflow: hidden;
}

.oj-table .oj-tag-list .oj-badge {
  max-width: 100%;
  overflow-wrap: anywhere;
  white-space: normal;
}

/* Card container that wraps tables and lists */
.oj-data-surface {
  background: var(--oj-panel);
  border: 1px solid var(--oj-border);
  border-radius: var(--oj-radius);
  box-shadow: var(--oj-shadow-sm);
  min-width: 0;
  overflow: hidden;
}

.oj-filter-bar {
  background: var(--oj-panel);
  border: 1px solid var(--oj-border);
  border-radius: var(--oj-radius);
  box-shadow: var(--oj-shadow-sm);
}

.oj-editorial-document {
  margin: 0 auto;
  max-width: 760px;
  padding: 30px 0;
}

.oj-editorial-document h1 {
  font-size: clamp(32px, 5vw, 46px);
  letter-spacing: -0.03em;
}

.oj-editorial-document p {
  line-height: 1.8;
}

.oj-meta-text,
.oj-meta-status {
  color: var(--oj-text);
  font-size: 13px;
  font-weight: 500;
}

.oj-meta-link,
.oj-inline-meta a {
  color: var(--oj-text);
  text-decoration: underline;
  text-decoration-color: transparent;
}

.oj-meta-link:hover,
.oj-inline-meta a:hover {
  color: var(--oj-link);
  text-decoration-color: currentColor;
}

.oj-inline-meta {
  align-items: baseline;
  color: var(--oj-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 7px;
  min-width: 0;
}

.oj-completion-mark {
  color: var(--oj-success);
  font-size: 17px;
  font-weight: 700;
}

.oj-tabular-number {
  color: var(--oj-heading);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.oj-status-code {
  align-items: center;
  color: var(--oj-heading);
  display: inline-flex;
  font-family: var(--oj-font-mono);
  font-size: 13px;
  font-weight: 600;
  justify-content: center;
  min-height: 44px;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 4px;
}

.oj-status-code:hover,
.oj-status-code:focus {
  color: var(--oj-heading);
  text-decoration-color: currentColor;
}

.oj-status-ac {
  color: var(--oj-success);
}

.oj-status-ac:hover,
.oj-status-ac:focus {
  color: var(--oj-success);
}

.oj-status-wa,
.oj-status-re {
  color: var(--oj-danger);
}

.oj-status-wa:hover,
.oj-status-wa:focus,
.oj-status-re:hover,
.oj-status-re:focus {
  color: var(--oj-danger);
}

.oj-status-tle,
.oj-status-mle,
.oj-status-pe {
  color: var(--oj-warning);
}

.oj-status-tle:hover,
.oj-status-tle:focus,
.oj-status-mle:hover,
.oj-status-mle:focus,
.oj-status-pe:hover,
.oj-status-pe:focus {
  color: var(--oj-warning);
}

.oj-reference-link {
  color: var(--oj-heading);
  font-size: 13px;
  font-weight: 500;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  text-decoration: underline;
  text-underline-offset: 4px;
}

/* Pagination */
.pagination {
  flex-wrap: wrap;
  gap: 4px;
}

.pagination .page-link {
  align-items: center;
  background: var(--oj-panel);
  border-color: var(--oj-border);
  border-radius: var(--oj-radius) !important;
  color: var(--oj-text-soft);
  display: inline-flex;
  font-weight: 500;
  justify-content: center;
  min-height: 44px;
  min-width: 36px;
  text-align: center;
}

.pagination .page-link:hover {
  background: var(--oj-primary-soft);
  border-color: var(--oj-border);
  color: var(--oj-link);
}

.pagination .active .page-link,
.pagination .page-item.active .page-link {
  background: var(--oj-primary);
  border-color: var(--oj-primary);
  color: var(--oj-primary-contrast);
}

.pagination .disabled .page-link {
  background: transparent;
  color: var(--oj-muted);
  opacity: 0.6;
}

/* Tabs and compact lists */
.oj-tabs {
  border-bottom-color: var(--oj-border);
  flex-wrap: nowrap;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}

.oj-tabs .nav-link {
  border-radius: 0;
  color: var(--oj-muted);
  font-weight: 500;
  white-space: nowrap;
}

.oj-tabs .nav-link.active {
  background: transparent;
  border-color: transparent transparent var(--oj-primary);
  border-bottom-width: 2px;
  color: var(--oj-link);
  font-weight: 600;
}

.oj-compact-list {
  display: grid;
  gap: 0;
}

.oj-compact-list-item {
  align-items: center;
  border-bottom: 1px solid var(--oj-border-faint);
  display: flex;
  gap: 14px;
  justify-content: space-between;
  min-width: 0;
  padding: 13px 0;
}

.oj-compact-list-item:last-child {
  border-bottom: 0;
}

.oj-compact-list-main {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
}

.oj-compact-list-title {
  color: var(--oj-heading);
  display: block;
  font-weight: 600;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.oj-compact-list-item > .oj-status-code {
  flex: 0 0 auto;
}

.oj-compact-list-item:hover {
  background: transparent;
}

.oj-solved-grid {
  display: grid;
  gap: 0;
}

.oj-solved-item {
  align-items: center;
  border-bottom: 1px solid var(--oj-border-faint);
  color: inherit;
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 15px 0;
  text-decoration: none;
  transition: background 0.15s ease;
}

.oj-solved-item:hover {
  background: var(--oj-hover-bg);
  color: inherit;
}

.oj-solved-main {
  min-width: 0;
}

.oj-solved-title {
  color: var(--oj-heading);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.oj-solved-metrics {
  color: var(--oj-muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 13px;
  gap: 9px;
  justify-content: flex-end;
  white-space: nowrap;
}

/* Profile */
.oj-profile-shell {
  display: grid;
  gap: 20px;
}

.oj-profile-hero {
  align-items: center;
  background: var(--oj-panel);
  border: 1px solid var(--oj-border);
  border-radius: var(--oj-radius-lg);
  box-shadow: var(--oj-shadow-sm);
  display: flex;
  gap: 20px;
  justify-content: space-between;
  padding: 22px 24px;
}

.oj-profile-identity {
  align-items: center;
  display: flex;
  gap: 16px;
  min-width: 0;
}

.oj-profile-name {
  font-size: clamp(24px, 3vw, 32px);
  font-weight: 700;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.oj-profile-name-link,
.oj-public-profile-name a {
  color: inherit;
  text-decoration: none;
}

.oj-profile-meta {
  color: var(--oj-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-top: 5px;
}

.oj-profile-tabs {
  border-bottom: 1px solid var(--oj-border);
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 0 4px;
  scrollbar-width: thin;
}

.oj-profile-tab {
  border-bottom: 2px solid transparent;
  color: var(--oj-muted);
  flex: 0 0 auto;
  font-size: 14px;
  font-weight: 500;
  padding: 11px 14px;
  text-decoration: none;
  white-space: nowrap;
}

.oj-profile-tab:hover {
  color: var(--oj-link);
}

.oj-profile-tab.active,
.oj-profile-tab[aria-current="page"] {
  border-bottom-color: var(--oj-primary);
  color: var(--oj-link);
  font-weight: 600;
}

.oj-profile-content-grid {
  align-items: start;
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
}

.oj-profile-actions {
  display: grid;
  gap: 10px;
}

.oj-profile-actions .btn {
  justify-content: flex-start;
}

.oj-profile-activity-grid {
  align-items: start;
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(0, 1.4fr) minmax(300px, 0.6fr);
}

.oj-search-row {
  align-items: end;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) auto auto;
}

.oj-settings-stack {
  display: grid;
  gap: 18px;
  margin: 0 auto;
  max-width: 820px;
  width: 100%;
}

.oj-settings-section {
  background: var(--oj-panel);
  border: 1px solid var(--oj-border);
  border-radius: var(--oj-radius-lg);
  box-shadow: var(--oj-shadow-sm);
  padding: 24px 26px;
}

.oj-settings-section-header {
  border-bottom: 1px solid var(--oj-border);
  margin: -2px 0 20px;
  padding-bottom: 15px;
}

.oj-settings-section-header h2 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 4px;
}

.oj-verification-callout {
  align-items: flex-start;
  background: var(--oj-warning-soft);
  border: 1px solid var(--oj-warning);
  border-radius: var(--oj-radius);
  display: flex;
  gap: 14px;
  justify-content: space-between;
  margin-bottom: 20px;
  padding: 13px 15px;
}

.oj-verification-callout.is-verified {
  background: var(--oj-success-soft);
  border-color: var(--oj-success);
}

.oj-login-method {
  align-items: center;
  border-bottom: 1px solid var(--oj-border-faint);
  display: flex;
  gap: 14px;
  justify-content: space-between;
  padding: 14px 0;
}

.oj-login-method:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.oj-danger-zone {
  background: var(--oj-panel);
  border-color: var(--oj-danger);
}

/* Rich content and code */
.oj-pre {
  background: var(--oj-panel-muted);
  border: 1px solid var(--oj-border);
  border-radius: var(--oj-control-radius);
  color: var(--oj-text-soft);
  font-size: 13px;
  margin: 0;
  padding: 15px;
  white-space: pre-wrap;
}

.oj-code-pre {
  background: var(--oj-code-bg);
  border-color: var(--oj-code-border);
  color: var(--oj-code-text);
  overflow-x: auto;
  white-space: pre;
}

.oj-rich-content {
  color: var(--oj-text-soft);
  line-height: 1.78;
  overflow-wrap: anywhere;
}

.oj-rich-content > :last-child {
  margin-bottom: 0;
}

.oj-rich-content img {
  border: 1px solid var(--oj-border);
  border-radius: var(--oj-radius);
  display: block;
  height: auto;
  margin: 18px 0;
  max-width: 100%;
}

.oj-rich-content table {
  border-collapse: collapse;
  display: block;
  margin: 18px 0;
  max-width: 100%;
  overflow-x: auto;
  width: max-content;
}

.oj-rich-content th,
.oj-rich-content td {
  border: 1px solid var(--oj-border);
  padding: 9px 11px;
}

.oj-rich-content th {
  background: var(--oj-panel-muted);
  color: var(--oj-heading);
  font-weight: 600;
}

.oj-rich-content code {
  background: var(--oj-panel-muted);
  border-radius: 6px;
  color: var(--oj-heading);
  font-size: 0.92em;
  padding: 2px 5px;
}

.oj-rich-content pre {
  background: var(--oj-panel-muted);
  border: 1px solid var(--oj-border);
  border-radius: var(--oj-control-radius);
  overflow-x: auto;
  padding: 15px;
}

.oj-rich-content pre code {
  background: transparent;
  padding: 0;
}

.oj-image-list {
  display: grid;
  gap: 12px;
}

.oj-image-item {
  align-items: center;
  border: 1px solid var(--oj-border);
  border-radius: var(--oj-radius);
  display: grid;
  gap: 14px;
  grid-template-columns: 96px minmax(0, 1fr) auto;
  padding: 13px;
}

.oj-image-item img {
  aspect-ratio: 4 / 3;
  border: 1px solid var(--oj-border);
  border-radius: var(--oj-radius);
  height: auto;
  object-fit: contain;
  width: 96px;
}

.oj-image-meta {
  min-width: 0;
}

/* Problem and submission helpers */
.oj-problem-detail-shell {
  align-items: flex-start;
}

.oj-problem-detail-main,
.oj-problem-detail-side {
  min-width: 0;
}

.oj-problem-title {
  color: var(--oj-heading);
  line-height: 1.16;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.oj-problem-tabs {
  flex-wrap: nowrap;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

.oj-problem-tabs .nav-link {
  white-space: nowrap;
}

.oj-problem-user-panels {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr;
}

.oj-performance-stack {
  display: grid;
  gap: 18px;
}

.oj-performance-progress {
  background: var(--oj-primary-soft);
  height: 8px;
}

.oj-performance-progress .progress-bar {
  background: var(--oj-primary);
}

.oj-submission-source textarea {
  background: var(--oj-code-bg);
  border-color: var(--oj-code-border);
  color: var(--oj-code-text);
  font-family: var(--oj-font-mono);
  font-size: 13px;
  line-height: 1.55;
  min-height: 300px;
  overflow: auto;
  resize: vertical;
  tab-size: 4;
  white-space: pre;
}

.oj-submission-link {
  color: inherit;
  text-decoration: none;
}

.oj-submission-link:hover {
  color: inherit;
}

.oj-submission-detail-row > td {
  background: var(--oj-panel-muted);
  border-bottom: 1px solid var(--oj-border-faint);
}

.oj-submission-inline-detail {
  padding: 18px;
}

.oj-submission-inline-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1.35fr) minmax(260px, 0.65fr);
}

.oj-submission-inline-heading {
  color: var(--oj-heading);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
}

.oj-inline-toggle {
  color: var(--oj-link);
  font-size: 12px;
  font-weight: 600;
  margin-left: -8px;
  padding-bottom: 0;
  padding-top: 2px;
  text-decoration: none;
}

.oj-filter-actions {
  align-self: end;
  display: flex;
  gap: 8px;
}

.oj-filter-actions .btn {
  min-height: 44px;
}

/* Footer */
.oj-footer {
  border-top: 1px solid var(--oj-border);
  color: var(--oj-muted);
  font-size: 13px;
  margin-top: 40px;
  padding: 22px 0 30px;
}

.oj-footer-inner {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  justify-content: space-between;
}

.oj-footer-brand {
  color: var(--oj-gold-deep);
  font-family: var(--oj-font-serif);
  font-size: 15px;
}

.oj-footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
}

.oj-footer-links a {
  color: var(--oj-muted);
  text-decoration: none;
}

.oj-footer-links a:hover {
  color: var(--oj-link);
  text-decoration: underline;
}

/* Responsive */
@media (max-width: 991.98px) {
  .oj-navbar {
    min-height: 60px;
  }

  .oj-navbar .navbar-toggler {
    background: var(--oj-panel);
    border-color: var(--oj-border-strong);
    border-radius: var(--oj-radius);
    box-shadow: none;
    margin-left: auto;
    min-height: 44px;
    padding: 8px 10px;
  }

  .oj-navbar .navbar-toggler:focus {
    box-shadow: var(--oj-focus);
  }

  .oj-navbar .navbar-collapse {
    background: var(--oj-panel);
    border: 1px solid var(--oj-border);
    border-radius: var(--oj-radius);
    box-shadow: var(--oj-shadow-md);
    flex-basis: 100%;
    margin-bottom: 12px;
    padding: 10px;
    width: 100%;
  }

  .oj-navbar .navbar-nav {
    gap: 5px;
    margin-left: 0;
    width: 100%;
  }

  .oj-navbar .nav-item,
  .oj-navbar .nav-link,
  .oj-navbar .navbar-nav form,
  .oj-navbar .navbar-nav .btn {
    width: 100%;
  }

  .oj-navbar .nav-link {
    border-radius: var(--oj-radius);
    min-height: 44px;
    padding: 10px 12px !important;
  }

  .oj-account-nav {
    border-top: 1px solid var(--oj-border);
    margin-top: 8px;
    padding-top: 8px;
  }

  .oj-theme-toggle {
    width: 100%;
  }

  .oj-user-menu-toggle {
    max-width: none;
  }

  .oj-user-menu-wrap .oj-user-menu-toggle {
    flex: 1 1 auto;
    min-width: 0;
    width: auto;
  }

  .oj-user-menu-wrap .oj-user-menu-dropdown-toggle {
    flex: 0 0 48px;
    width: 48px;
  }

  .oj-user-menu {
    border: 0;
    box-shadow: none;
    margin-top: 2px;
    width: 100%;
  }

  .oj-profile-content-grid,
  .oj-profile-activity-grid {
    grid-template-columns: 1fr;
  }

  .oj-home-hero {
    grid-template-columns: 1fr;
  }

  .oj-problem-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 767.98px) {
  body {
    font-size: 14px;
  }

  .oj-main {
    padding-bottom: 34px;
    padding-top: 22px;
  }

  .oj-page-heading,
  .oj-responsive-heading {
    align-items: stretch !important;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 13px;
  }

  .oj-page-heading .btn {
    width: 100%;
  }

  .oj-heading-actions {
    align-items: flex-start;
    justify-content: flex-start;
    width: 100%;
  }

  .oj-section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .oj-stat-grid,
  .oj-home-stat-grid,
  .oj-problem-grid {
    grid-template-columns: 1fr;
  }

  .oj-profile-hero {
    align-items: flex-start;
    flex-direction: column;
    padding: 18px;
  }

  .oj-profile-identity .oj-avatar-lg {
    font-size: 23px;
    height: 60px;
    width: 60px;
  }

  .oj-metric-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .oj-profile-tabs {
    margin-left: -12px;
    margin-right: -12px;
    padding-left: 12px;
    padding-right: 12px;
  }

  .oj-search-row {
    grid-template-columns: 1fr;
  }

  .oj-search-row .btn {
    width: 100%;
  }

  .oj-settings-section {
    padding: 20px;
  }

  .oj-verification-callout,
  .oj-login-method {
    align-items: stretch;
    flex-direction: column;
  }

  .oj-form-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .oj-form-actions .btn {
    width: 100%;
  }

  .oj-home-hero {
    padding: 22px;
  }

  .oj-filter-actions {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .oj-filter-actions .btn {
    width: 100%;
  }

  form.oj-panel > .row {
    --bs-gutter-x: 0;
    margin-left: 0;
    margin-right: 0;
  }

  .oj-table-cards {
    border-collapse: collapse;
    border-spacing: 0;
    min-width: 0;
  }

  .oj-table-cards thead {
    display: none;
  }

  .oj-table-cards tbody,
  .oj-table-cards tr,
  .oj-table-cards td {
    display: block;
    width: 100%;
  }

  .oj-table-cards tbody tr {
    background: transparent;
    border-bottom: 1px solid var(--oj-border);
    border-radius: 0;
    box-shadow: none;
    margin-bottom: 0;
    overflow: visible;
    padding: 10px 0;
  }

  .oj-table-cards tbody tr.oj-submission-detail-row {
    border: 0;
    box-shadow: none;
    margin-top: 0;
  }

  .oj-table-cards td {
    border-bottom: 0;
    padding: 8px 0;
  }

  .oj-table-cards td:last-child {
    border-bottom: 0;
  }

  .oj-front-table.oj-table-cards td[data-label] {
    align-items: center;
  }

  .oj-table-cards td[data-label] {
    display: grid;
    gap: 9px;
    grid-template-columns: minmax(92px, 0.35fr) minmax(0, 1fr);
  }

  .oj-front-table.oj-table-cards td.oj-table-align-center {
    text-align: left;
  }

  .oj-table-cards .oj-completion-cell:not(.is-complete) {
    display: none;
  }

  .oj-table-cards .oj-status-code {
    justify-content: flex-start;
  }

  .oj-front-table.oj-table-cards .oj-submission-submitted-actions {
    align-items: flex-start;
    justify-self: start;
  }

  .oj-table-cards td[data-label]::before {
    color: var(--oj-muted);
    content: attr(data-label);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.05em;
    line-height: 1.4;
    text-transform: uppercase;
  }

  .oj-table-cards td.oj-table-actions,
  .oj-table-cards td[data-label].oj-table-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-start;
    min-width: 0;
    width: 100%;
  }

  .oj-table-cards td.oj-table-actions::before {
    flex: 0 0 100%;
  }

  .oj-table-cards .oj-table-actions .btn,
  .oj-table-cards .oj-table-actions form {
    flex: 1 1 auto;
    margin: 0;
  }

  .oj-table-scroll {
    max-height: none;
  }

  .oj-compact-list-item {
    align-items: flex-start;
  }

  .oj-solved-item {
    align-items: start;
    grid-template-columns: 1fr;
  }

  .oj-solved-metrics {
    justify-content: flex-start;
  }

  .oj-problem-detail-shell {
    display: block;
    margin-left: 0;
    margin-right: 0;
  }

  .oj-problem-detail-main,
  .oj-problem-detail-side {
    padding-left: 0;
    padding-right: 0;
    width: 100%;
  }

  .oj-problem-detail-side {
    margin-top: 22px;
  }

  .oj-problem-title {
    font-size: 25px;
  }

  .oj-problem-user-panels,
  .oj-submission-inline-grid {
    grid-template-columns: 1fr;
  }

  .oj-submission-source textarea {
    min-height: 240px;
  }

  .oj-image-item {
    align-items: stretch;
    grid-template-columns: 1fr;
  }

  .oj-image-item img {
    width: 100%;
  }

  .pagination {
    justify-content: center !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }
}
