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

:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface-hover: #243044;
  --border: #2d3a4f;
  --text: #e7ecf3;
  --text-muted: #8b9cb3;
  --accent: #4f8cff;
  --accent-hover: #3d78e8;
  --danger: #ff6b6b;
  --radius: 12px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

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

button,
input {
  font: inherit;
}

.header {
  border-bottom: 1px solid var(--border);
  background: rgba(26, 35, 50, 0.95);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.875rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo {
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}

.breadcrumb {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.breadcrumb a:hover {
  color: var(--text);
}

.breadcrumb .sep {
  opacity: 0.5;
}

.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

.view-login {
  min-height: calc(100vh - 3rem);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
}

.login-card h1 {
  margin: 0 0 0.35rem;
  font-size: 1.5rem;
}

.subtitle {
  margin: 0 0 1.5rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

#login-form label {
  display: block;
  margin-bottom: 1rem;
}

#login-form span {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

#login-form input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}

#login-form input:focus {
  outline: 2px solid rgba(79, 140, 255, 0.45);
  border-color: var(--accent);
}

.remember-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.25rem 0 1rem;
  cursor: pointer;
  user-select: none;
}

.remember-row input[type='checkbox'] {
  width: 1rem;
  height: 1rem;
  margin: 0;
  accent-color: var(--accent);
}

.remember-row span {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.error {
  color: var(--danger);
  font-size: 0.875rem;
  margin: 0 0 1rem;
}

.page-header {
  margin-bottom: 1.5rem;
}

.page-header h2 {
  margin: 0 0 0.25rem;
  font-size: 1.35rem;
}

.page-header p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1rem;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.15s, border-color 0.15s;
}

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

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

.btn-secondary {
  background: var(--surface-hover);
  border-color: var(--border);
  color: var(--text);
}

.btn-secondary:hover {
  background: #2c3a50;
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-muted);
}

.btn-ghost:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.btn-block {
  width: 100%;
}

.grid {
  display: grid;
  gap: 1rem;
}

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

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

.resource-list-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.resource-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.resource-table th,
.resource-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.resource-table th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: rgba(0, 0, 0, 0.15);
}

.resource-table tbody tr:last-child td {
  border-bottom: none;
}

.resource-row {
  cursor: pointer;
  transition: background 0.15s;
}

.resource-row:hover {
  background: var(--surface-hover);
}

.col-thumb {
  width: 72px;
}

.col-id {
  width: 110px;
}

.col-kind {
  width: 96px;
  white-space: nowrap;
}

.kind-tag {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  background: rgba(79, 140, 255, 0.12);
  color: #a8c7ff;
}

.kind-a4,
.kind-a4-crop {
  background: rgba(255, 170, 80, 0.15);
  color: #ffc285;
}

.kind-empty {
  background: transparent;
  color: var(--text-muted);
}

.detail-meta {
  margin: 0.35rem 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.col-time {
  width: 180px;
  white-space: nowrap;
}

.col-meta {
  width: 160px;
  white-space: nowrap;
  color: var(--text-muted);
}

.col-layers {
  min-width: 180px;
}

.list-thumb {
  width: 48px;
  height: 64px;
  object-fit: contain;
  display: block;
  border-radius: 6px;
  background: #111822;
}

.list-thumb-placeholder {
  width: 48px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #111822;
  border-radius: 6px;
}

.list-thumb-placeholder .folder-icon {
  width: 28px;
  height: 28px;
  opacity: 0.55;
}

.path-text {
  font-family: ui-monospace, monospace;
  font-size: 0.82rem;
  color: var(--text-muted);
  word-break: break-all;
}

.layer-tag {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  margin: 0.1rem 0.2rem 0.1rem 0;
  border-radius: 999px;
  background: rgba(79, 140, 255, 0.15);
  color: #a8c7ff;
  font-size: 0.75rem;
}

.layer-tag-empty {
  background: transparent;
  color: var(--text-muted);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  cursor: pointer;
}

.card:hover {
  transform: translateY(-2px);
  border-color: rgba(79, 140, 255, 0.45);
  box-shadow: var(--shadow);
}

.card-date {
  padding: 1.25rem 1rem;
  text-align: center;
}

.card-date .icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.card-date .label {
  font-weight: 600;
  font-size: 1rem;
}

.card-resource .thumb-wrap {
  aspect-ratio: 3 / 4;
  background: #111822;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.card-resource img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.card-resource .folder-icon {
  width: 64px;
  height: 64px;
  opacity: 0.55;
}

.card-resource .meta {
  padding: 0.75rem;
}

.card-resource .id {
  font-family: ui-monospace, monospace;
  font-size: 0.85rem;
  word-break: break-all;
}

.empty,
.loading {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem;
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 420px) 1fr;
  gap: 1.5rem;
  align-items: start;
}

.detail-side {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.preview-label {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

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

.detail-preview {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.detail-preview img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 8px;
}

.detail-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.detail-panel h3 {
  margin: 1.25rem 0 0.75rem;
  font-size: 1rem;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.file-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.detail-main-preview img {
  max-height: 70vh;
  object-fit: contain;
}

.file-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.file-info {
  flex: 1;
  min-width: 0;
}

.file-meta {
  display: block;
  margin-top: 0.2rem;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.file-list li:last-child {
  border-bottom: none;
}

.file-name {
  font-family: ui-monospace, monospace;
  font-size: 0.875rem;
  word-break: break-all;
}

.file-size {
  color: var(--text-muted);
  font-size: 0.8rem;
  white-space: nowrap;
}
