:root {
  color-scheme: light;
  --bg: #f7f8fb;
  --surface: #ffffff;
  --surface-2: #eef4f1;
  --text: #20242c;
  --muted: #6f7785;
  --faint: #98a1ae;
  --line: #dde2ea;
  --green: #2f7d5c;
  --blue: #2f6fcb;
  --orange: #f28c28;
  --red: #d64545;
  --dark: #3f4652;
  --shadow: 0 14px 34px rgba(31, 43, 68, 0.12);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: default;
  opacity: 0.55;
}

.app-shell {
  width: min(100%, 760px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 22px 18px 104px;
}

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

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--green);
  font-size: 13px;
  font-weight: 800;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 30px;
  line-height: 1.1;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 8px;
  font-size: 18px;
  line-height: 1.25;
}

h3 {
  margin-bottom: 0;
  font-size: 15px;
}

.icon-button,
.tab,
.filter,
.mini-button,
.primary-button,
.secondary-button,
.danger-button,
.detail-close {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

.icon-button {
  min-width: 60px;
  padding: 0 14px;
}

.icon-button.is-active {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.primary-button,
.secondary-button,
.danger-button,
.mini-button {
  padding: 0 13px;
  font-weight: 800;
}

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

.secondary-button {
  background: #fff;
  color: var(--green);
}

.danger-button,
.mini-button.danger {
  border-color: rgba(214, 69, 69, 0.35);
  background: #fff3f3;
  color: var(--red);
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.tab {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.tab.is-active {
  background: var(--text);
  color: #fff;
}

.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 132px;
  gap: 10px;
  margin-bottom: 12px;
}

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

.search-box,
.sort-box {
  display: block;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}

input,
select {
  min-height: 44px;
  padding: 0 12px;
}

textarea {
  min-height: 110px;
  padding: 11px 12px;
  resize: vertical;
}

.filters {
  display: flex;
  gap: 8px;
  padding-bottom: 10px;
  overflow-x: auto;
  scrollbar-width: none;
}

.filters::-webkit-scrollbar {
  display: none;
}

.filter {
  flex: 0 0 auto;
  padding: 0 14px;
  color: var(--muted);
  font-weight: 700;
}

.filter.is-active {
  border-color: var(--green);
  background: var(--surface-2);
  color: var(--green);
}

.summary-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 6px 0 14px;
  color: var(--muted);
  font-size: 13px;
}

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

.work-card,
.mini-card {
  position: relative;
  display: grid;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.work-card {
  gap: 9px;
}

.mini-card {
  gap: 8px;
  width: 112px;
  flex: 0 0 112px;
}

.mini-card > span:last-child {
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(47, 111, 203, 0.3);
  outline-offset: 3px;
}

.cover {
  position: relative;
  aspect-ratio: 0.72;
  overflow: hidden;
  border-radius: 8px;
  background:
    radial-gradient(circle at 20% 18%, rgba(255, 255, 255, 0.5), transparent 22%),
    linear-gradient(145deg, var(--cover-a), var(--cover-b));
  box-shadow: var(--shadow);
}

.cover-mini {
  width: 100%;
}

.cover::before {
  content: "";
  position: absolute;
  inset: 13px;
  z-index: 1;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 6px;
  pointer-events: none;
}

.cover-img {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cover-img:not([hidden]) ~ .cover-mark {
  opacity: 0;
}

.cover-mark {
  position: absolute;
  right: 12px;
  bottom: 10px;
  z-index: 1;
  color: rgba(255, 255, 255, 0.88);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(34px, 13vw, 58px);
  line-height: 0.9;
}

.status-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
  max-width: calc(100% - 20px);
  padding: 5px 9px;
  border-radius: 4px;
  background: var(--status-color);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.select-check {
  position: absolute;
  right: 10px;
  top: 10px;
  z-index: 2;
  display: none;
  width: 26px;
  height: 26px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: transparent;
  font-weight: 900;
}

.selecting .select-check {
  display: grid;
}

.work-card.is-selected .select-check {
  background: var(--green);
  color: #fff;
}

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

.work-title {
  display: block;
  min-width: 0;
  overflow: hidden;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nationality-badge {
  flex: 0 0 auto;
  max-width: 72px;
  overflow: hidden;
  padding: 2px 5px;
  border-radius: 4px;
  background: #ffdde2;
  color: #b83245;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.work-meta,
.work-progress,
.work-tags {
  display: block;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.work-tags {
  margin-top: 2px;
}

.bulk-bar {
  position: fixed;
  right: 12px;
  bottom: 78px;
  left: 12px;
  z-index: 8;
  display: grid;
  gap: 12px;
  max-width: 736px;
  margin: 0 auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.bulk-bar strong,
.bulk-bar span {
  display: block;
}

.bulk-bar span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.bulk-controls {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.stats-grid article,
.home-section,
.candidate,
.tag-row,
.tool-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.stats-grid article {
  padding: 13px 10px;
}

.stats-grid strong {
  display: block;
  font-size: 22px;
}

.stats-grid span,
.candidate p,
.tool-panel p,
.empty-inline,
.tag-row small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.section-stack,
.candidate-list,
.tag-manager {
  display: grid;
  gap: 14px;
}

.home-section {
  padding: 14px;
}

.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-header h2 {
  margin-bottom: 4px;
}

.section-header p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 12px;
}

.section-actions {
  display: flex;
  gap: 6px;
}

.rail {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.rail::-webkit-scrollbar {
  display: none;
}

.candidate {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
}

.candidate .cover {
  align-self: start;
}

.candidate h2 {
  margin-bottom: 4px;
  font-size: 16px;
}

.candidate p {
  margin-bottom: 5px;
}

.candidate .primary-button {
  grid-column: 1 / -1;
}

.tag-manager h2 {
  margin: 12px 0 0;
}

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

.tag-pill {
  padding: 7px 10px;
  border-radius: 999px;
  background: #edf0f5;
  color: #4b5565;
  font-size: 12px;
  font-weight: 800;
}

.tag-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  align-items: center;
  gap: 8px;
  padding: 10px;
}

.tag-row strong,
.tag-row small {
  display: block;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  margin-bottom: 18px;
}

.inline-form button {
  min-height: 44px;
  border: 1px solid var(--green);
  border-radius: 8px;
  background: var(--green);
  color: #fff;
  font-weight: 800;
}

.tool-panel {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
  padding: 14px;
}

.tool-panel textarea {
  min-height: 220px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.empty-state {
  margin-top: 42px;
  text-align: center;
  color: var(--muted);
}

.empty-state h2 {
  color: var(--text);
  font-size: 18px;
}

.sheet-dialog {
  width: min(100% - 24px, 620px);
  max-height: calc(100vh - 36px);
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  box-shadow: var(--shadow);
}

.sheet-dialog::backdrop {
  background: rgba(20, 24, 31, 0.48);
}

.sheet {
  display: grid;
  gap: 16px;
  padding: 16px;
}

.sheet-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.sheet-header h2 {
  margin-bottom: 0;
  font-size: 22px;
}

.detail-close {
  flex: 0 0 auto;
  width: 38px;
  min-height: 38px;
  font-size: 20px;
}

.detail-top {
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr);
  gap: 14px;
}

.detail-top .cover {
  width: 118px;
}

.detail-muted {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

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

.field {
  display: grid;
  gap: 6px;
}

.field.full {
  grid-column: 1 / -1;
}

.field span,
.sub-editor h3 {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.sub-editor {
  display: grid;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.sub-editor header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.editable-row {
  display: grid;
  grid-template-columns: 1fr 0.7fr 1.5fr auto;
  gap: 8px;
  margin-bottom: 8px;
}

.sheet-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 4px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 82px;
  z-index: 20;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--text);
  color: #fff;
  font-size: 13px;
  box-shadow: var(--shadow);
}

.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  max-width: 760px;
  margin: 0 auto;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
}

.nav-item {
  display: grid;
  place-items: center;
  gap: 2px;
  min-height: 50px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.nav-item span:first-child {
  font-size: 18px;
  line-height: 1;
}

.nav-item.is-active {
  background: var(--surface-2);
  color: var(--green);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (min-width: 560px) {
  .app-shell {
    padding-top: 34px;
  }

  .card-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .bulk-bar {
    grid-template-columns: 1fr 1.8fr;
    align-items: center;
  }
}

@media (max-width: 460px) {
  .search-row,
  .form-grid,
  .editable-row {
    grid-template-columns: 1fr;
  }

  .bulk-controls {
    grid-template-columns: 1fr 1fr;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .candidate {
    grid-template-columns: 78px minmax(0, 1fr);
  }

  .tag-row {
    grid-template-columns: 1fr auto auto;
  }

  .tag-row .danger {
    grid-column: 2 / -1;
  }

  .detail-top {
    grid-template-columns: 92px minmax(0, 1fr);
  }

  .detail-top .cover {
    width: 92px;
  }
}
