.scan-workspace[hidden],
.empty-state[hidden] {
  display: none !important;
}

.empty-state {
  text-align: center;
  padding: 48px 22px;
}

.empty-state h2 {
  margin: 0 0 10px;
}

.empty-state p {
  margin: 0 0 22px;
}

.scan-status {
  margin-bottom: 12px;
  transition: box-shadow 0.2s ease, background-color 0.2s ease;
}

.scan-workspace .scan-table-card {
  padding: 0;
}

.scan-status.is-flash {
  box-shadow: 0 0 0 3px rgba(255, 157, 0, 0.55);
  background-color: rgba(255, 157, 0, 0.08);
}

.scan-status__row {
  display: flex;
  flex-wrap: wrap;
  gap: 18px 32px;
  align-items: baseline;
}

.scan-status__item strong {
  font-size: 1.5rem;
  color: var(--zh-accent);
  margin: 0 6px;
}

.scan-status__progress {
  margin-left: auto;
}

.status-message {
  margin: 8px 0 0;
  font-weight: 700;
  color: var(--zh-muted);
  line-height: 1.3;
}

.status-message.is-active {
  color: var(--zh-text);
}

.status-message.is-done {
  color: var(--zh-ok);
}

.scan-camera-row {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.camera-scan-btn {
  flex: 1 1 160px;
  max-width: 360px;
}

.duplicate-banner {
  margin: 10px 0 0;
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(239, 68, 68, 0.1);
  color: var(--zh-bad);
  font-weight: 800;
  font-size: 0.9rem;
}

.scan-input.is-duplicate {
  border-color: rgba(239, 68, 68, 0.55);
  background: rgba(239, 68, 68, 0.04);
}

.settings-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
  font-weight: 700;
  cursor: pointer;
}

.settings-check input {
  margin-top: 3px;
  width: 18px;
  height: 18px;
  accent-color: var(--zh-accent);
}

.settings-field {
  margin-bottom: 12px;
}

.settings-hint {
  margin-top: 0;
  font-size: 0.88rem;
}

.camera-actions {
  justify-content: space-between;
}

.camera-modal__panel {
  width: min(520px, 100%);
}

.camera-modal .dialog-body {
  padding: 14px 16px 16px;
}

.camera-modal .dialog-title {
  margin-bottom: 2px;
}

.camera-modal .dialog-text {
  margin-bottom: 8px;
}

.camera-reader {
  width: 100%;
  height: 140px;
  max-height: 140px;
  min-height: 0;
  border-radius: 10px;
  overflow: hidden;
  background: #0f172a;
  position: relative;
}

.camera-reader > div {
  max-height: 140px !important;
  overflow: hidden !important;
}

.camera-reader video {
  width: 100% !important;
  height: 140px !important;
  max-height: 140px !important;
  object-fit: cover !important;
  border: none !important;
  display: block !important;
}

.camera-video {
  width: 100%;
  height: 140px;
  max-height: 140px;
  border-radius: 10px;
  background: #0f172a;
  object-fit: cover;
}

.camera-hint {
  margin: 6px 0 0;
  font-weight: 700;
  font-size: 0.82rem;
  line-height: 1.25;
}

.camera-modal .dialog-actions {
  margin-top: 10px;
}

.scan-table-card {
  padding: 0;
  overflow: hidden;
}

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

.scan-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.scan-table th,
.scan-table td {
  padding: 4px 10px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  text-align: left;
  vertical-align: middle;
}

.scan-table th {
  position: sticky;
  top: 0;
  background: var(--zh-surface);
  font-weight: 800;
  color: var(--zh-muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  z-index: 1;
}

.scan-table .col-item,
.scan-table .col-pc {
  min-width: 88px;
  text-align: left;
  font-weight: 800;
  color: var(--zh-accent);
  white-space: nowrap;
}

.scan-table tr.is-current {
  background: rgba(255, 157, 0, 0.1);
}

.scan-table tr.is-current td.col-item,
.scan-table tr.is-current td.col-pc {
  box-shadow: inset 3px 0 0 var(--zh-accent);
}

.scan-table tr.is-complete {
  background: rgba(34, 197, 94, 0.06);
}

.scan-input {
  width: 100%;
  min-width: 140px;
  padding: 6px 10px;
  border: 2px solid rgba(15, 23, 42, 0.12);
  border-radius: 8px;
  font: inherit;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.9rem;
  line-height: 1.2;
  background: #fff;
  color: var(--zh-text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.scan-input:focus {
  outline: none;
  border-color: var(--zh-accent);
  box-shadow: 0 0 0 3px rgba(255, 157, 0, 0.25);
}

.scan-input.is-filled {
  border-color: rgba(34, 197, 94, 0.45);
  background: rgba(34, 197, 94, 0.04);
}

.scan-input.is-active {
  border-color: var(--zh-accent);
  background: #fffdf8;
}

/* Modals */
body.modal-open {
  overflow: hidden;
}

.modal {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10001;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal.is-open {
  display: flex !important;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
}

.modal__panel {
  position: relative;
  z-index: 1;
  width: min(560px, 100%);
  max-height: min(90vh, 900px);
  overflow: auto;
  border: 1px solid var(--zh-card-border);
  border-radius: 18px;
  box-shadow: var(--zh-card-shadow);
  background: var(--zh-surface);
  color: var(--zh-text);
}

.modal__panel--wide {
  width: min(640px, 100%);
}

.form-field--full {
  display: block;
  margin-bottom: 14px;
}

.empty-state__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

.project-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: min(52vh, 420px);
  overflow: auto;
  margin-bottom: 18px;
  padding-right: 2px;
}

.project-list-empty {
  margin: 0;
  padding: 12px 0;
  text-align: center;
}

.project-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--zh-card-border);
  border-radius: 14px;
  background: var(--zh-surface-2, rgba(255, 255, 255, 0.03));
}

.project-card.is-active {
  border-color: var(--zh-accent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--zh-accent) 35%, transparent);
}

.project-card__main {
  flex: 1;
  min-width: 0;
}

.project-card__title {
  display: block;
  font-size: 0.98rem;
  font-weight: 800;
  color: var(--zh-text);
  line-height: 1.3;
  word-break: break-word;
}

.project-card__meta {
  margin: 4px 0 0;
  font-size: 0.82rem;
  line-height: 1.4;
}

.project-card__actions {
  display: flex;
  flex-shrink: 0;
  flex-direction: column;
  gap: 6px;
}

.project-card__actions .btn {
  min-width: 88px;
  padding: 7px 10px;
  font-size: 0.78rem;
}

.project-card__delete {
  color: var(--zh-danger, #b91c1c);
}

@media (max-width: 520px) {
  .project-card {
    flex-direction: column;
    align-items: stretch;
  }

  .project-card__actions {
    flex-direction: row;
  }

  .project-card__actions .btn {
    flex: 1;
    min-width: 0;
  }
}

/* Fallback for cached pages still using native <dialog> */
dialog.scan-dialog {
  border: 1px solid var(--zh-card-border);
  border-radius: 18px;
  padding: 0;
  max-width: min(560px, calc(100vw - 32px));
  width: calc(100% - 32px);
  box-shadow: var(--zh-card-shadow);
  background: var(--zh-surface);
  color: var(--zh-text);
}

dialog.scan-dialog::backdrop {
  background: rgba(15, 23, 42, 0.55);
}

.dialog-body {
  padding: 22px;
}

.dialog-title {
  margin: 0 0 8px;
  font-size: 1.25rem;
  font-weight: 900;
  color: var(--zh-accent);
}

.dialog-text {
  margin: 0 0 18px;
  color: var(--zh-muted);
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.45;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.zh-input {
  width: 100%;
  padding: 11px 14px;
  border: 2px solid rgba(15, 23, 42, 0.12);
  border-radius: 12px;
  font: inherit;
  font-weight: 700;
  background: #fff;
  color: var(--zh-text);
}

.zh-input:focus {
  outline: none;
  border-color: var(--zh-accent);
  box-shadow: 0 0 0 3px rgba(255, 157, 0, 0.22);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--zh-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-section {
  margin-bottom: 16px;
}

.col-names {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.form-error {
  margin: 0 0 8px;
  color: var(--zh-bad);
  font-weight: 800;
  font-size: 0.9rem;
}

.voice-details {
  margin-bottom: 16px;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 12px;
  padding: 10px 14px;
}

.voice-details summary {
  cursor: pointer;
  font-weight: 800;
  color: var(--zh-text);
}

.voice-details .form-grid {
  margin-top: 12px;
  margin-bottom: 0;
}

.wizard-preview {
  margin-bottom: 4px;
  padding: 14px 16px;
  background: rgba(255, 157, 0, 0.06);
}

.wizard-preview__text {
  margin: 6px 0 0;
  font-weight: 700;
  font-size: 0.92rem;
  line-height: 1.5;
}

.header-actions .btn:disabled,
.header-actions .btn.secondary:disabled {
  opacity: 0.45;
  pointer-events: none;
}

@media (max-width: 768px) {
  body.zh-force-fixed-header {
    padding-top: var(--zh-fixed-header-pad, 76px);
  }

  body.zh-force-fixed-header .header-wrapper {
    padding-left: max(10px, 3vw);
    padding-right: max(10px, 3vw);
    padding-bottom: 6px;
  }

  body.zh-force-fixed-header .header-container {
    padding: 8px 10px;
    gap: 6px;
    border-radius: 12px;
  }

  body.zh-force-fixed-header .logo {
    height: 34px;
  }

  body.zh-force-fixed-header .brand-block {
    gap: 8px;
  }

  body.zh-force-fixed-header .brand-title {
    font-size: 0.92rem;
  }

  body.zh-force-fixed-header .brand-tagline {
    font-size: 0.68rem;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 52vw;
  }

  body.zh-force-fixed-header .header-nav-toggle {
    min-width: 34px;
    min-height: 34px;
    padding: 0 8px;
    border-radius: 10px;
  }

  body.zh-force-fixed-header .header-nav-drawer {
    padding-top: 6px;
    gap: 6px;
    margin-top: 0;
  }

  body.zh-force-fixed-header .header-actions {
    gap: 6px;
  }

  body.zh-force-fixed-header .header-actions .btn,
  body.zh-force-fixed-header .header-actions .btn.secondary {
    min-height: 36px;
    padding: 6px 10px;
    font-size: 0.72rem;
  }

  .wrap {
    padding-bottom: 14px;
  }

  main .card,
  .empty-state.card {
    padding: 11px 10px;
    border-radius: 12px;
  }

  .scan-workspace .scan-status {
    padding: 7px 8px;
    margin-bottom: 6px;
    border-radius: 10px;
  }

  .scan-workspace .scan-table-card {
    border-radius: 10px;
  }

  .empty-state {
    padding: 24px 12px;
  }

  .empty-state h2 {
    font-size: 1.05rem;
    margin-bottom: 6px;
  }

  .empty-state p {
    margin-bottom: 14px;
    font-size: 0.84rem;
  }

  .scan-status__progress {
    margin-left: 0;
  }

  .scan-status__row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px 8px;
    align-items: end;
  }

  .scan-status__item {
    font-size: 0.68rem;
    line-height: 1.15;
  }

  .scan-status__item strong {
    display: block;
    font-size: 0.95rem;
    margin: 1px 0 0;
  }

  .status-message {
    margin: 4px 0 0;
    font-size: 0.74rem;
    line-height: 1.2;
  }

  .duplicate-banner {
    margin: 4px 0 0;
    padding: 5px 8px;
    font-size: 0.72rem;
    border-radius: 6px;
  }

  .scan-camera-row {
    margin-top: 5px;
    gap: 5px;
  }

  .camera-scan-btn,
  .scan-camera-row .btn {
    min-height: 32px;
    padding: 5px 8px;
    font-size: 0.74rem;
  }

  .scan-table {
    font-size: 0.8rem;
  }

  .scan-table th,
  .scan-table td {
    padding: 1px 5px;
  }

  .scan-table th {
    font-size: 0.62rem;
    letter-spacing: 0.03em;
    padding-top: 4px;
    padding-bottom: 4px;
  }

  .scan-table .col-item,
  .scan-table .col-pc {
    min-width: 48px;
    font-size: 0.72rem;
    line-height: 1.2;
  }

  .scan-input {
    min-width: 72px;
    padding: 3px 6px;
    font-size: 16px;
    border-radius: 6px;
    border-width: 1.5px;
    line-height: 1.15;
  }

  .scan-table tr.is-current td {
    padding-top: 2px;
    padding-bottom: 2px;
  }

  .modal:not(.camera-modal) {
    padding: 0;
    align-items: flex-end;
  }

  .modal:not(.camera-modal) .modal__panel {
    width: 100%;
    max-height: 88vh;
    border-radius: 14px 14px 0 0;
  }

  .modal.camera-modal {
    align-items: flex-end;
    padding: 0 8px 10px;
  }

  .modal.camera-modal .camera-modal__panel {
    width: 100%;
    max-height: none;
    border-radius: 14px;
  }

  .camera-modal .dialog-body {
    padding: 10px 10px 12px;
  }

  .camera-modal .dialog-title {
    font-size: 0.92rem;
    margin-bottom: 0;
  }

  .camera-modal .dialog-text {
    margin-bottom: 6px;
    font-size: 0.76rem;
    line-height: 1.25;
  }

  .camera-reader {
    height: 118px;
    max-height: 118px;
    border-radius: 8px;
  }

  .camera-reader > div {
    max-height: 118px !important;
  }

  .camera-reader video {
    height: 118px !important;
    max-height: 118px !important;
  }

  .camera-video {
    height: 118px;
    max-height: 118px;
    border-radius: 8px;
  }

  .camera-hint {
    margin-top: 4px;
    font-size: 0.72rem;
  }

  .camera-modal .dialog-actions {
    margin-top: 8px;
    gap: 6px;
  }

  .camera-modal .dialog-actions .btn {
    min-height: 32px;
    padding: 5px 10px;
    font-size: 0.74rem;
  }

  .dialog-body {
    padding: 12px 12px 14px;
  }

  .dialog-title {
    font-size: 1rem;
    margin-bottom: 4px;
  }

  .dialog-text {
    margin-bottom: 10px;
    font-size: 0.82rem;
    line-height: 1.35;
  }

  .dialog-actions {
    margin-top: 10px;
    gap: 6px;
  }

  .dialog-actions .btn {
    min-height: 36px;
    padding: 7px 12px;
    font-size: 0.78rem;
  }

  .zh-input {
    padding: 8px 10px;
    font-size: 0.86rem;
    border-radius: 10px;
  }

  .form-grid {
    gap: 8px;
    margin-bottom: 10px;
    grid-template-columns: 1fr;
  }

  .form-label {
    font-size: 0.68rem;
  }

  .form-field {
    gap: 3px;
  }

  .form-section {
    margin-bottom: 10px;
  }

  .col-names {
    gap: 6px;
    margin-top: 4px;
  }

  .form-error {
    font-size: 0.76rem;
  }

  .voice-details {
    margin-bottom: 10px;
    padding: 7px 10px;
    border-radius: 10px;
  }

  .voice-details .form-grid {
    margin-top: 8px;
  }

  .wizard-preview {
    padding: 8px 10px;
  }

  .wizard-preview__text {
    margin-top: 4px;
    font-size: 0.8rem;
    line-height: 1.35;
  }

  .settings-check {
    gap: 8px;
    margin-bottom: 10px;
    font-size: 0.84rem;
  }

  .settings-check input {
    width: 16px;
    height: 16px;
  }

  .settings-hint {
    font-size: 0.78rem;
  }

  main .btn,
  .empty-state .btn {
    padding: 8px 12px;
    font-size: 0.8rem;
  }
}
