:root {
  --ink: #172129;
  --muted: #64717c;
  --line: #dce2e6;
  --paper: #fff;
  --bg: #f3f5f4;
  --accent: #16895b;
  --accent-dark: #0e6844;
  --soft: #eaf6f0;
  --danger: #b14343;
  font-family: "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
[hidden] { display: none !important; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .48; }

.app-header {
  background: #17352d;
  color: #fff;
  padding: 30px max(28px, calc((100vw - 1180px) / 2));
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 30px;
}
.app-header h1 { margin: 3px 0 6px; font-size: clamp(24px, 3vw, 34px); letter-spacing: .02em; }
.app-header p { margin: 0; color: #cfe1da; }
.eyebrow { text-transform: uppercase; font-size: 12px; letter-spacing: .16em; font-weight: 700; }
.header-actions { display: flex; align-items: center; gap: 12px; }
.current-user { color: #cfe1da; font-size: 13px; }
.header-link { border: 1px solid rgba(255,255,255,.35); border-radius: 8px; padding: 9px 12px; color: #fff; background: transparent; font-weight: 700; }
.header-link:hover { background: rgba(255,255,255,.1); }

.login-view { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: linear-gradient(145deg, #17352d, #0d211c); }
.login-card { width: min(420px, 100%); display: grid; gap: 16px; padding: 32px; border-radius: 16px; background: #fff; box-shadow: 0 24px 70px rgba(0,0,0,.28); }
.login-card h1 { margin: 0; font-size: 30px; }
.login-card p { margin: 0; color: var(--muted); }
.login-eyebrow { color: var(--accent-dark) !important; }
.login-button { width: 100%; margin-top: 4px; padding: 12px 16px; }
.login-error { min-height: 20px; color: var(--danger) !important; font-size: 13px; font-weight: 700; }

main { width: min(1180px, calc(100% - 36px)); margin: 26px auto 60px; }
.panel, .pages-section { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 24px; margin-bottom: 20px; box-shadow: 0 6px 22px rgba(28, 45, 37, .04); }
.section-title { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 20px; }
.section-title h2 { margin: 0 0 4px; font-size: 20px; }
.section-title p { margin: 0; color: var(--muted); font-size: 14px; }
.step { width: 29px; height: 29px; border-radius: 50%; display: grid; place-items: center; background: var(--soft); color: var(--accent-dark); font-weight: 800; }

label { font-size: 13px; color: #47545e; font-weight: 700; }
input, textarea { width: 100%; border: 1px solid #cfd7dc; border-radius: 8px; color: var(--ink); background: #fff; }
input { margin-top: 6px; padding: 10px 11px; }
input:focus, textarea:focus { outline: 3px solid rgba(22, 137, 91, .14); border-color: var(--accent); }
.dropzone { min-height: 140px; border: 2px dashed #b9c6c0; border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; background: #fbfcfb; transition: .18s ease; }
.dropzone:hover, .dropzone.dragging { border-color: var(--accent); background: var(--soft); }
.dropzone input { display: none; }
.dropzone strong { color: var(--accent-dark); font-size: 16px; }
.dropzone small { color: var(--muted); font-weight: 400; }
.upload-icon { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #fff; font-size: 24px; line-height: 1; }
.upload-limit { margin: 10px 0 0; text-align: right; color: var(--muted); font-size: 13px; }

.primary, .secondary, .icon-btn, .danger {
  border-radius: 8px; border: 1px solid transparent; font-weight: 700;
}
.primary { padding: 12px 20px; background: #fff; color: #17352d; white-space: nowrap; }
.secondary { padding: 9px 14px; background: var(--accent); color: #fff; }
.secondary:hover { background: var(--accent-dark); }
.icon-btn { width: 36px; height: 36px; background: #fff; border-color: var(--line); color: #34424b; }
.icon-btn:hover { background: #f0f3f2; }
.danger { padding: 8px 12px; background: #fff; color: var(--danger); border-color: #ebcaca; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-bottom: 16px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 14px; }
.empty-state { padding: 48px 20px; text-align: center; color: #7a868e; }
.pages { display: grid; gap: 20px; margin-top: 20px; }
.page-card { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.page-head { min-height: 52px; padding: 8px 13px; display: flex; align-items: center; justify-content: space-between; background: #f7f9f8; border-bottom: 1px solid var(--line); }
.page-head-left, .page-actions { display: flex; align-items: center; gap: 8px; }
.page-number { font-weight: 800; }
.order-label { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.order-input { width: 58px; margin: 0; padding: 7px 8px; text-align: center; font-weight: 800; }
.file-name { color: var(--muted); font-size: 12px; max-width: 300px; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.page-body { display: grid; grid-template-columns: minmax(260px, .8fr) minmax(340px, 1.2fr); min-height: 460px; }
.image-pane { background: #e9eeeb; display: flex; justify-content: center; align-items: flex-start; padding: 16px; min-width: 0; }
.image-pane img { max-width: 100%; max-height: 620px; object-fit: contain; box-shadow: 0 3px 16px rgba(0, 0, 0, .12); }
.hover-preview {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(10, 18, 15, .78);
  pointer-events: none;
}
.image-pane:hover .hover-preview { display: flex; }
.image-pane .hover-preview img {
  width: auto;
  height: auto;
  max-width: calc(100vw - 48px);
  max-height: calc(100vh - 48px);
  object-fit: contain;
  box-shadow: 0 18px 60px rgba(0, 0, 0, .5);
}
.translation-pane { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.title-field { display: grid; gap: 5px; }
.title-field input { margin: 0; }
.translation-pane textarea { min-height: 340px; flex: 1; padding: 14px; resize: vertical; line-height: 1.75; }
.translation-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.translation-top h3 { margin: 0; font-size: 16px; }
.status { font-size: 12px; color: var(--muted); }
.status.review { color: #9a5e14; font-weight: 700; }
.page-note { margin: 0; padding: 9px 11px; background: #fff8e9; color: #76501d; font-size: 12px; border-radius: 7px; }

.toast { position: fixed; right: 20px; bottom: 20px; max-width: 420px; padding: 12px 16px; border-radius: 9px; background: #18231f; color: #fff; box-shadow: 0 8px 26px rgba(0,0,0,.2); opacity: 0; transform: translateY(8px); pointer-events: none; transition: .2s; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #8b3030; }

@media (max-width: 780px) {
  .app-header { align-items: flex-start; flex-direction: column; }
  .page-body { grid-template-columns: 1fr; }
  .file-name { max-width: 130px; }
  .page-actions { flex-wrap: wrap; justify-content: flex-end; }
  .header-actions { flex-wrap: wrap; }
  .hover-preview { display: none !important; }
}
