:root {
  --ink: #1f2933;
  --muted: #667085;
  --line: #d8dee6;
  --paper: #f6f8fa;
  --panel: #ffffff;
  --accent: #2f6f5e;
  --accent-dark: #245648;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(31,41,51,.035) 1px, transparent 1px),
    linear-gradient(0deg, rgba(31,41,51,.035) 1px, transparent 1px),
    var(--paper);
  background-size: 36px 36px;
  font-family: "Segoe UI", "Malgun Gothic", Arial, sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  background:
    radial-gradient(circle at 42px 120px, rgba(255,255,255,.12) 0 9px, transparent 10px),
    radial-gradient(circle at 198px 230px, rgba(0,0,0,.35) 0 10px, transparent 11px),
    #18251f;
  color: #fff;
  padding: 24px 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 30px;
}

.brand-logo {
  width: 64px;
  height: 64px;
  border-radius: 8px;
  object-fit: cover;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: #b7c5bd;
  margin-top: 4px;
}

.nav,
.subnav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav a {
  border-radius: 8px;
  color: #dfe8e3;
  padding: 11px 12px;
}

.nav a.active,
.nav a:hover {
  background: #2f6f5e;
  color: #fff;
}

.subnav {
  margin: 4px 0 8px 18px;
}

.subnav a {
  font-size: 14px;
  padding: 8px 10px;
}

.content {
  padding: 28px;
}

.auth-shell {
  grid-template-columns: 320px 1fr;
}

.auth-content {
  display: grid;
  place-items: center;
  min-height: 100vh;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 22px;
  border-bottom: 2px solid rgba(47,111,94,.18);
  padding-bottom: 16px;
}

.topbar h1 {
  margin: 0;
  font-size: 28px;
}

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

.account,
.actions,
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  background: #fff;
  cursor: pointer;
  font-weight: 700;
}

.button.small {
  min-height: 30px;
  padding: 0 9px;
  font-size: 13px;
}

.button.disabled {
  opacity: .45;
  pointer-events: none;
}

.button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.button.primary:hover {
  background: var(--accent-dark);
}

.button.danger {
  border-color: #f1b3ab;
  background: #fff4f2;
  color: var(--danger);
}

.button.ghost {
  background: transparent;
}

.flash {
  border: 1px solid #f7c5bd;
  border-radius: 8px;
  background: #fff4f2;
  color: var(--danger);
  padding: 10px 14px;
  margin-bottom: 18px;
}

.flash p {
  margin: 0;
}

.toolbar {
  justify-content: space-between;
  margin-bottom: 16px;
}

.export-toolbar {
  margin-bottom: 10px;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

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

.tabs a {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px 14px;
  color: var(--muted);
}

.tabs a.active {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.search-form {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.search-form input {
  min-width: 250px;
}

.search-form .button {
  min-width: 76px;
  min-height: 44px;
  padding: 0 20px;
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.search-form .button:hover {
  background: var(--accent-dark);
}

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

.post-card,
.auth-panel,
.form,
.detail,
.table-wrap,
.empty {
  background:
    radial-gradient(circle at calc(100% - 28px) 28px, rgba(31,41,51,.06) 0 9px, transparent 10px),
    var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.post-card a {
  display: grid;
  grid-template-columns: 1fr 130px;
  gap: 16px;
  padding: 18px;
}

.post-card h2 {
  margin: 0 0 8px;
  font-size: 19px;
}

.post-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.post-card img {
  width: 130px;
  height: 92px;
  object-fit: cover;
  border-radius: 6px;
}

.post-card footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  padding: 10px 18px;
}

.auth-panel {
  max-width: 420px;
  width: min(420px, 100%);
  padding: 24px;
}

.login-logo {
  display: block;
  width: 240px;
  max-width: 100%;
  margin: 0 auto 18px;
  border-radius: 8px;
}

.form {
  display: grid;
  gap: 14px;
  padding: 20px;
}

.form label {
  display: grid;
  gap: 7px;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  font: inherit;
}

textarea {
  resize: vertical;
}

.editor {
  max-width: 820px;
}

.detail {
  padding: 22px;
  max-width: 900px;
  position: relative;
  overflow: hidden;
}

.detail-wide {
  max-width: min(1480px, 100%);
}

.detail::before {
  content: "";
  position: absolute;
  right: -50px;
  top: -50px;
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(17,17,17,.09) 0 38%, transparent 39%);
  pointer-events: none;
}

.detail-image {
  width: 100%;
  max-height: 520px;
  object-fit: contain;
  border-radius: 8px;
  background: #eef1f4;
  margin-bottom: 18px;
}

.detail-content {
  line-height: 1.75;
  margin-bottom: 22px;
  white-space: pre-wrap;
}

.hint {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.current-image {
  display: grid;
  grid-template-columns: 160px 1fr;
  align-items: center;
  gap: 12px;
}

.current-image img {
  width: 160px;
  height: 110px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--line);
}

.sheet-builder {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7faf8;
  padding: 16px;
}

.sheet-builder h2 {
  margin: 0;
  font-size: 18px;
}

.participant-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}

.team-builder-fields {
  display: grid;
  gap: 12px;
}

.team-builder-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 10px;
}

.team-card-grid,
.team-roster-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.team-create-card,
.team-roster-card,
.team-round-card,
.team-match-card {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.team-create-card h3,
.team-round-card h3,
.team-standings h3 {
  margin: 0;
  color: var(--accent-dark);
}

.team-member-list,
.member-edit-list {
  display: grid;
  gap: 6px;
  max-height: 240px;
  overflow: auto;
}

.check-item {
  display: flex !important;
  align-items: center;
  grid-template-columns: none !important;
  gap: 8px !important;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
  font-weight: 600 !important;
}

.check-item input {
  width: auto;
}

.check-item.compact {
  padding: 7px 9px;
  font-size: 14px;
}

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

.sheet-scroll {
  overflow-x: auto;
  margin-bottom: 12px;
}

.source-sheet-scroll {
  border: 1px solid #cfd8e3;
  border-radius: 8px;
  background: #eef2f6;
  max-height: 72vh;
  overflow: auto;
}

.league-sheet {
  min-width: 680px;
}

.league-sheet th,
.league-sheet td {
  padding: 6px;
}

.league-sheet input {
  min-width: 110px;
  border-radius: 6px;
  padding: 8px;
  background: #fff;
}

.league-sheet th input {
  font-weight: 800;
  background: #eef3ef;
}

.source-sheet {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  font-size: 14px;
}

.source-sheet th,
.source-sheet td {
  min-width: 118px;
  max-width: 220px;
  height: 38px;
  border-right: 1px solid #d8dee6;
  border-bottom: 1px solid #d8dee6;
  background: #fff;
  padding: 0;
  vertical-align: middle;
}

.source-sheet thead th {
  position: sticky;
  top: 0;
  z-index: 4;
  background: #eef3f7;
}

.source-sheet input {
  display: block;
  min-width: 118px;
  width: 100%;
  height: 38px;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 7px 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #202936;
  font-size: 14px;
  white-space: nowrap;
}

.source-sheet .sheet-cell {
  display: block;
  min-width: 118px;
  width: 100%;
  height: 38px;
  padding: 7px 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #202936;
  font-size: 14px;
  white-space: nowrap;
}

.source-sheet input:focus {
  position: relative;
  z-index: 6;
  outline: 2px solid #2563eb;
  outline-offset: -2px;
  background: #fff;
}

.source-sheet .sheet-corner,
.source-sheet .sheet-row-index {
  position: sticky;
  left: 0;
  z-index: 5;
  min-width: 46px;
  width: 46px;
  max-width: 46px;
  background: #e8edf3;
  color: #64748b;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.source-sheet .sheet-corner {
  top: 0;
  z-index: 7;
}

.source-sheet .sheet-first-col {
  position: sticky;
  left: 46px;
  z-index: 3;
  min-width: 150px;
  background: #fbfcfd;
  box-shadow: 1px 0 0 #cfd8e3;
}

.source-sheet thead .sheet-first-col {
  z-index: 6;
  background: #e8edf3;
}

.source-sheet .sheet-empty {
  background: #f8fafc;
}

.source-sheet .sheet-round-row th,
.source-sheet .sheet-round-row td,
.source-sheet .sheet-round-row .sheet-first-col,
.source-sheet .sheet-round-cell {
  background: #203f50;
}

.source-sheet .sheet-round-row input,
.source-sheet .sheet-round-cell input,
.source-sheet .sheet-round-row .sheet-cell,
.source-sheet .sheet-round-cell .sheet-cell {
  color: #fff;
  font-weight: 900;
  letter-spacing: 0;
}

.source-sheet .sheet-team-row th,
.source-sheet .sheet-team-row td,
.source-sheet .sheet-team-cell {
  background: #e7f1ed;
}

.source-sheet .sheet-team-row input,
.source-sheet .sheet-team-cell input,
.source-sheet .sheet-team-row .sheet-cell,
.source-sheet .sheet-team-cell .sheet-cell {
  color: #245648;
  font-weight: 900;
}

.source-sheet .sheet-played-row {
  background: #fff;
}

.source-sheet .sheet-win-cell,
.source-sheet .sheet-loss-cell {
  min-width: 48px;
  max-width: 64px;
}

.source-sheet .sheet-win-cell input,
.source-sheet .sheet-loss-cell input,
.source-sheet .sheet-win-cell .sheet-cell,
.source-sheet .sheet-loss-cell .sheet-cell {
  text-align: center;
  font-size: 18px;
  font-weight: 900;
}

.source-sheet .sheet-win-cell {
  background: #e9f7ef;
}

.source-sheet .sheet-win-cell input,
.source-sheet .sheet-win-cell .sheet-cell {
  color: #137333;
}

.source-sheet .sheet-loss-cell {
  background: #fff1f2;
}

.source-sheet .sheet-loss-cell input,
.source-sheet .sheet-loss-cell .sheet-cell {
  color: #b42318;
}

.source-sheet .sheet-player-cell input,
.source-sheet .sheet-player-cell .sheet-cell {
  font-weight: 700;
}

.sheet-source-link {
  white-space: nowrap;
}

.workbook-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 10px;
  margin-bottom: 8px;
}

.workbook-tabs a {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #475467;
  padding: 9px 12px;
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
}

.workbook-tabs a.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.ranking-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 12px;
}

.ranking-strip span {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f6faf8;
  padding: 8px 10px;
  font-weight: 700;
}

.team-league-summary {
  display: grid;
  grid-template-columns: 170px 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

.progress-card,
.team-standings {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7faf8;
  padding: 14px;
}

.progress-card span {
  display: block;
  color: var(--muted);
  font-weight: 800;
  margin-bottom: 8px;
}

.progress-card strong {
  color: var(--accent);
  font-size: 24px;
}

.team-standings {
  overflow-x: auto;
}

.team-standings table,
.order-table {
  min-width: 760px;
}

.team-roster-grid,
.team-rounds {
  margin-bottom: 14px;
}

.team-rounds {
  display: grid;
  gap: 14px;
}

.team-round-head,
.team-match-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.team-match-head input {
  max-width: 360px;
}

.order-table-wrap {
  overflow-x: auto;
}

.order-table input,
.order-table select {
  min-width: 120px;
  padding: 8px;
}

.order-table input[type="number"] {
  min-width: 70px;
}

.tsumego-layout {
  display: grid;
  grid-template-columns: minmax(520px, 1fr) 340px;
  gap: 18px;
  align-items: start;
}

.tsumego-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 18px;
}

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

.point-pill {
  border: 1px solid var(--accent);
  border-radius: 8px;
  color: var(--accent-dark);
  background: #f1f7f4;
  padding: 9px 12px;
}

.tsumego-form {
  display: grid;
  gap: 14px;
}

.tsumego-board-wrap {
  width: min(100%, 720px);
  overflow: auto;
  border: 2px solid #5d3b18;
  background: #d7a85a;
}

.tsumego-board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--cols), 44px);
  grid-template-rows: repeat(var(--rows), 44px);
  width: max-content;
  min-width: 100%;
  justify-content: center;
  padding: 22px;
  background: #d7a85a;
}

.board-point {
  position: relative;
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 0;
  width: 44px;
  height: 44px;
}

.grid-line,
.stone-disc {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.grid-line.horizontal {
  width: 100%;
  height: 2px;
  background: rgba(74,44,18,.62);
}

.grid-line.vertical {
  width: 2px;
  height: 100%;
  background: rgba(74,44,18,.62);
}

.stone-disc {
  width: 72%;
  height: 72%;
  border-radius: 50%;
  z-index: 1;
}

.board-point.stone {
  cursor: default;
}

.stone-disc.black {
  background: radial-gradient(circle at 32% 28%, #555 0 8%, #171717 45%, #050505 100%);
  box-shadow: 0 3px 7px rgba(0,0,0,.35);
}

.stone-disc.white {
  background: radial-gradient(circle at 30% 26%, #fff 0 16%, #ececec 58%, #cfcfcf 100%);
  border: 1px solid rgba(0,0,0,.22);
  box-shadow: 0 3px 7px rgba(0,0,0,.18);
}

.board-point.selected::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 88%;
  height: 88%;
  border: 3px solid #c43d2b;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
}

.preview-disc {
  opacity: .78;
}

.tsumego-actions {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}

.tsumego-actions strong {
  display: block;
  margin-bottom: 6px;
}

.tsumego-side {
  display: grid;
  gap: 14px;
}

.winner-list {
  display: grid;
  gap: 8px;
}

.winner-row {
  display: grid;
  grid-template-columns: 54px 1fr 72px;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.winner-row span {
  font-size: 22px;
  font-weight: 900;
}

.winner-row em {
  color: var(--accent-dark);
  font-style: normal;
  font-weight: 900;
  text-align: right;
}

.bracket-scroll {
  overflow-x: auto;
  padding: 8px 0 14px;
}

.tournament-results {
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    radial-gradient(circle at calc(100% - 28px) 28px, rgba(47,111,94,.12) 0 10px, transparent 11px),
    #f7faf8;
  padding: 16px;
  margin: 4px 0 14px;
  max-width: 420px;
}

.tournament-results h3 {
  margin: 0 0 10px;
  color: var(--accent-dark);
}

.result-row {
  display: grid;
  grid-template-columns: 86px 1fr;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding: 10px 0;
}

.result-row span {
  color: var(--muted);
  font-weight: 800;
}

.result-row strong {
  font-size: 18px;
}

.bracket {
  display: flex;
  align-items: stretch;
  gap: 42px;
  min-width: 760px;
}

.bracket-round {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  gap: 18px;
  min-width: 190px;
}

.bracket-round h3 {
  margin: 0 0 2px;
  color: var(--accent-dark);
  font-size: 16px;
}

.bracket-match {
  position: relative;
  display: grid;
  gap: 6px;
  border: 2px solid #111;
  border-radius: 4px;
  background: #fff;
  padding: 9px;
  min-height: 106px;
}

.bracket-match::after {
  content: "";
  position: absolute;
  right: -44px;
  top: 50%;
  width: 42px;
  border-top: 2px solid #111;
}

.bracket-round:last-child .bracket-match::after {
  display: none;
}

.bracket-match input,
.bracket-match select {
  border-radius: 4px;
  padding: 8px;
}

.bracket-match input[readonly] {
  background: #f3f5f6;
  font-weight: 700;
}

.bracket-match select {
  border-color: var(--accent);
  color: var(--accent-dark);
  font-weight: 800;
}

.bracket-4 .bracket-round:first-child {
  gap: 70px;
}

.bracket-8 .bracket-round:first-child {
  gap: 30px;
}

.bracket-16 .bracket-round:first-child {
  gap: 12px;
}

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

table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px;
  text-align: left;
}

th {
  background: #f2f5f3;
}

.table-wrap {
  overflow-x: auto;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 0 0 16px;
}

.pagination.bottom {
  margin: 16px 0 0;
}

.pagination span {
  color: var(--muted);
  font-weight: 800;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.row-actions form {
  margin: 0;
}

th:last-child,
td:last-child {
  white-space: nowrap;
}

.empty {
  padding: 30px;
  color: var(--muted);
  text-align: center;
}

.empty.small {
  padding: 16px;
}

.hero {
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 18px;
  background: #111;
  box-shadow: 0 18px 40px rgba(24,37,31,.14);
}

.hero img {
  display: block;
  width: 100%;
  max-height: 360px;
  object-fit: cover;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.stats-strip {
  display: grid;
  grid-template-columns: minmax(220px, 320px) 1fr;
  gap: 18px;
  margin-bottom: 18px;
}

.stat-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 8px;
}

.stat-card strong {
  font-size: 36px;
  color: var(--accent);
}

.baduk-board-mini {
  position: relative;
  min-height: 96px;
  border: 1px solid #c99f5a;
  border-radius: 8px;
  background:
    linear-gradient(90deg, transparent 31px, rgba(88,58,24,.55) 32px, transparent 33px),
    linear-gradient(0deg, transparent 31px, rgba(88,58,24,.55) 32px, transparent 33px),
    #d8ad66;
  background-size: 32px 32px;
  overflow: hidden;
}

.baduk-board-mini span {
  position: absolute;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  box-shadow: 0 5px 12px rgba(0,0,0,.22);
}

.baduk-board-mini span:nth-child(1) {
  left: 44px;
  top: 18px;
  background: #111;
}

.baduk-board-mini span:nth-child(2) {
  left: 106px;
  top: 50px;
  background: #fff;
}

.baduk-board-mini span:nth-child(3) {
  right: 84px;
  top: 18px;
  background: #fff;
}

.baduk-board-mini span:nth-child(4) {
  right: 36px;
  bottom: 16px;
  background: #111;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

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

.panel-head h2 {
  margin: 0;
  font-size: 18px;
}

.panel-head a {
  color: var(--accent);
  font-weight: 700;
}

.compact-list {
  display: grid;
  gap: 10px;
}

.compact-item,
.rank-item {
  display: flex;
  align-items: center;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.compact-item {
  align-items: flex-start;
  flex-direction: column;
}

.compact-item span,
.rank-item em {
  color: var(--muted);
  font-style: normal;
}

.rank-item span {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: #eef6f2;
  color: var(--accent);
  font-weight: 800;
}

.rank-item strong {
  flex: 1;
}

.medal {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  margin-left: 6px;
  color: #1f2933;
  font-size: 12px;
  font-weight: 900;
  box-shadow: inset 0 -2px 4px rgba(0,0,0,.16), 0 2px 6px rgba(0,0,0,.12);
}

.medal-1 {
  background: linear-gradient(135deg, #ffe78a, #d6a419);
}

.medal-2 {
  background: linear-gradient(135deg, #f5f7fa, #a7b0bd);
}

.medal-3 {
  background: linear-gradient(135deg, #e7b27d, #a56532);
}

.rating-user-link {
  color: var(--accent-dark);
  font-weight: 800;
}

.rating-user-link:hover {
  text-decoration: underline;
}

.rating-profile {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.result-badge {
  display: inline-grid;
  place-items: center;
  min-width: 34px;
  min-height: 28px;
  border-radius: 8px;
  font-weight: 900;
}

.result-badge.win {
  background: #eef8f2;
  color: #16794f;
}

.result-badge.loss {
  background: #fff1ef;
  color: #b42318;
}

.calendar-nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.calendar-nav strong {
  min-width: 130px;
  text-align: center;
  font-size: 20px;
}

.calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel);
}

.weekday,
.day {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.weekday:nth-child(7n),
.day:nth-child(7n) {
  border-right: 0;
}

.weekday {
  background: #eef3ef;
  padding: 10px;
  text-align: center;
  font-weight: 800;
}

.day {
  min-height: 132px;
  padding: 8px;
}

.muted-day {
  background: #f7f8f9;
  color: #a1aab3;
}

.day-number {
  margin-bottom: 8px;
  font-weight: 800;
}

.schedule-chip {
  display: grid;
  gap: 3px;
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  background: #f1f7f4;
  padding: 8px;
  margin-bottom: 6px;
  font-size: 13px;
}

.schedule-chip span {
  color: var(--muted);
}

.chip-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.chip-actions a,
.chip-actions button {
  border: 0;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  padding: 0;
}

.rating-form {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: end;
  margin-bottom: 18px;
}

.split.wide {
  grid-template-columns: minmax(320px, .8fr) minmax(420px, 1.2fr);
}

@media (max-width: 860px) {
  .detail-wide {
    max-width: 100%;
  }

  .source-sheet-scroll {
    max-height: 68vh;
  }

  .source-sheet {
    font-size: 13px;
  }

  .source-sheet th,
  .source-sheet td,
  .source-sheet input {
    min-width: 106px;
  }

  .source-sheet .sheet-first-col {
    left: 40px;
    min-width: 128px;
  }

  .source-sheet .sheet-corner,
  .source-sheet .sheet-row-index {
    min-width: 40px;
    width: 40px;
    max-width: 40px;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .topbar,
  .toolbar,
  .toolbar-left,
  .search-form,
  .account {
    align-items: stretch;
    flex-direction: column;
  }

  .auth-content {
    min-height: auto;
  }

  .search-form input {
    min-width: 0;
  }

  .post-card a,
  .split,
  .split.wide,
  .dashboard-grid,
  .stats-strip,
  .team-builder-options,
  .team-league-summary,
  .tsumego-layout,
  .rating-profile,
  .rating-form {
    grid-template-columns: 1fr;
  }

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

  .calendar {
    display: block;
  }

  .weekday {
    display: none;
  }

  .day {
    min-height: auto;
    border-right: 0;
  }

  .post-card img {
    width: 100%;
    height: 180px;
  }

  .current-image {
    grid-template-columns: 1fr;
  }

  .current-image img {
    width: 100%;
    height: 180px;
  }
}

/* 2026 visual refresh: modernize the existing Flask templates without changing markup. */
:root {
  --ink: #17211c;
  --muted: #64746c;
  --line: #dde7e1;
  --paper: #f3f7f2;
  --panel: rgba(255, 255, 255, .92);
  --accent: #2e7d5f;
  --accent-dark: #18543f;
  --danger: #b42318;
  --shadow-soft: 0 18px 48px rgba(24, 48, 38, .11);
  --shadow-card: 0 10px 28px rgba(24, 48, 38, .08);
  --radius-xl: 22px;
  --radius-lg: 16px;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 8%, rgba(128, 181, 143, .28), transparent 30%),
    radial-gradient(circle at 90% 12%, rgba(218, 172, 95, .18), transparent 26%),
    linear-gradient(135deg, #f8fbf6 0%, #eef6ef 52%, #f9f2e6 100%);
}

.app-shell {
  grid-template-columns: 282px minmax(0, 1fr);
}

.auth-shell {
  grid-template-columns: 360px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 42px 84px, rgba(255, 255, 255, .14) 0 12px, transparent 13px),
    radial-gradient(circle at 215px 220px, rgba(0, 0, 0, .38) 0 14px, transparent 15px),
    linear-gradient(165deg, #10251c 0%, #18372a 54%, #0d1713 100%);
  box-shadow: 12px 0 36px rgba(22, 45, 35, .14);
}

.brand {
  border: 1px solid rgba(255, 255, 255, .13);
  border-radius: var(--radius-xl);
  background: rgba(255, 255, 255, .08);
  padding: 12px;
  backdrop-filter: blur(12px);
}

.brand-logo {
  border-radius: 18px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, .25);
}

.brand strong {
  font-size: 20px;
  letter-spacing: -.02em;
}

.nav a {
  border: 1px solid transparent;
  border-radius: 14px;
  transition: background .16s ease, border-color .16s ease, transform .16s ease;
}

.nav a.active,
.nav a:hover {
  border-color: rgba(255, 255, 255, .14);
  background: rgba(255, 255, 255, .13);
  transform: translateX(2px);
}

.content {
  max-width: 1260px;
  width: 100%;
  padding: 34px;
}

.auth-content {
  max-width: none;
}

.topbar {
  border: 1px solid rgba(46, 125, 95, .12);
  border-radius: var(--radius-xl);
  background: rgba(255, 255, 255, .68);
  box-shadow: var(--shadow-card);
  padding: 22px;
  backdrop-filter: blur(14px);
}

.topbar h1 {
  color: var(--accent-dark);
  font-size: clamp(26px, 3vw, 38px);
  letter-spacing: -.045em;
}

.button,
input,
textarea,
select,
.tabs a {
  border-radius: 14px;
}

.button {
  box-shadow: 0 6px 16px rgba(24, 48, 38, .06);
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}

.button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(24, 48, 38, .1);
}

.button.primary {
  border-color: var(--accent);
  background: linear-gradient(135deg, var(--accent), #43a174);
}

.post-card,
.auth-panel,
.form,
.detail,
.table-wrap,
.empty,
.panel,
.stat-card,
.sheet-panel,
.tsumego-panel,
.team-create-card,
.team-roster-card,
.team-round-card,
.team-match-card,
.progress-card,
.team-standings,
.tournament-results {
  border-radius: var(--radius-lg);
  border-color: rgba(46, 125, 95, .14);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .96), rgba(255, 255, 255, .88)),
    var(--panel);
  box-shadow: var(--shadow-card);
}

.hero {
  border-radius: var(--radius-xl);
  background: linear-gradient(135deg, #10251c, #2e7d5f);
  box-shadow: var(--shadow-soft);
}

.hero img {
  max-height: 420px;
}

.flash {
  border-radius: 14px;
}

table {
  overflow: hidden;
}

th {
  color: var(--accent-dark);
  background: #edf5ef;
}

.calendar {
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.day,
.weekday {
  background-clip: padding-box;
}

.schedule-chip,
.rank-item span,
.ranking-strip span,
.point-pill {
  border-radius: 999px;
}

.baduk-board-mini,
.tsumego-board-wrap {
  border-radius: var(--radius-lg);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .35);
}

@media (max-width: 860px) {
  .app-shell,
  .auth-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    min-height: auto;
    box-shadow: none;
  }

  .content {
    padding: 18px;
  }

  .topbar {
    padding: 18px;
  }
}
