/* ============================================
   ファイルビューア集 - 共通スタイル
   ============================================ */

:root {
  --color-bg: #f4f6f9;
  --color-surface: #ffffff;
  --color-border: #e1e5ea;
  --color-text: #1f2937;
  --color-text-muted: #6b7280;
  --color-primary: #2563eb;
  --color-primary-dark: #1d4ed8;
  --color-accent: #0ea5e9;
  --color-danger: #dc2626;
  --color-warning: #b45309;
  --color-warning-bg: #fef3c7;
  --radius: 10px;
  --max-width: 1080px;
  font-size: 16px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic UI",
    "Segoe UI", system-ui, -apple-system, Roboto, "Noto Sans JP", sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--color-primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
}

/* ---------- Header ---------- */

.site-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0.9rem 1.2rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.logo {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--color-text);
  white-space: nowrap;
}

.logo:hover {
  text-decoration: none;
  color: var(--color-primary);
}

.tool-nav {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tool-nav a {
  display: inline-block;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  font-size: 0.92rem;
  color: var(--color-text-muted);
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.tool-nav a:hover {
  background: #eef2ff;
  color: var(--color-primary);
  text-decoration: none;
}

.tool-nav a.active {
  background: var(--color-primary);
  color: #fff;
  font-weight: 600;
}

/* ---------- Layout ---------- */

main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.5rem 1.2rem 3rem;
}

.page-title {
  font-size: 1.6rem;
  margin: 0.4rem 0 0.3rem;
}

.page-desc {
  color: var(--color-text-muted);
  margin: 0 0 1.4rem;
  font-size: 0.98rem;
}

/* ---------- Notice boxes ---------- */

.notice {
  background: #eef6ff;
  border: 1px solid #cfe4fd;
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
  margin-bottom: 1.4rem;
  font-size: 0.92rem;
  color: #1e3a5f;
}

.notice ul {
  margin: 0.3rem 0 0;
  padding-left: 1.3rem;
}

.notice.warning {
  background: var(--color-warning-bg);
  border-color: #fde68a;
  color: var(--color-warning);
}

/* ---------- Drop zone ---------- */

.dropzone {
  border: 2px dashed #b7c2d0;
  border-radius: var(--radius);
  background: var(--color-surface);
  padding: 2.4rem 1.2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  margin-bottom: 1.4rem;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--color-primary);
  background: #f0f6ff;
}

.dropzone .dz-icon {
  font-size: 2.4rem;
  margin-bottom: 0.4rem;
}

.dropzone .dz-main {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.dropzone .dz-sub {
  font-size: 0.88rem;
  color: var(--color-text-muted);
}

.dropzone input[type="file"] {
  display: none;
}

/* ---------- Buttons & controls ---------- */

.btn {
  display: inline-block;
  padding: 0.5rem 1.1rem;
  border-radius: 6px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 0.92rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  text-decoration: none;
}

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

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

.btn-sm {
  padding: 0.3rem 0.7rem;
  font-size: 0.82rem;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin-bottom: 1rem;
}

.toolbar label {
  font-size: 0.88rem;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.toolbar select,
.toolbar input[type="text"],
.toolbar input[type="search"] {
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 0.9rem;
  background: var(--color-surface);
}

.spacer {
  flex: 1 1 auto;
}

/* ---------- File info ---------- */

.file-info {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.88rem;
  color: var(--color-text-muted);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.7rem 1rem;
  margin-bottom: 1rem;
}

.file-info strong {
  color: var(--color-text);
}

/* ---------- Tabs (sheets) ---------- */

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.8rem;
}

.tabs button {
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  border-radius: 6px 6px 0 0;
  cursor: pointer;
  font-size: 0.88rem;
  color: var(--color-text-muted);
}

.tabs button.active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
  font-weight: 600;
}

/* ---------- Table viewer ---------- */

.table-wrap {
  overflow: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  max-height: 70vh;
}

table.data-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.86rem;
  white-space: nowrap;
}

table.data-table th,
table.data-table td {
  border: 1px solid var(--color-border);
  padding: 0.35rem 0.6rem;
  text-align: left;
}

table.data-table thead th {
  background: #f1f5f9;
  position: sticky;
  top: 0;
  z-index: 1;
  font-weight: 600;
}

table.data-table tbody th {
  background: #f8fafc;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
}

table.data-table tbody tr:nth-child(even) {
  background: #fafbfc;
}

table.data-table tbody tr:hover {
  background: #eef6ff;
}

/* ---------- JSON tree ---------- */

.json-view {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem;
  overflow: auto;
  max-height: 70vh;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.86rem;
}

.json-tree ul {
  list-style: none;
  margin: 0;
  padding-left: 1.4rem;
  border-left: 1px dashed #d8dee8;
}

.json-tree > ul {
  padding-left: 0;
  border-left: none;
}

.json-tree li {
  margin: 0.1rem 0;
}

.json-toggle {
  cursor: pointer;
  user-select: none;
  display: inline-block;
  width: 1.1rem;
  color: var(--color-text-muted);
  font-weight: bold;
}

.json-key {
  color: #b45309;
}

.json-string { color: #15803d; }
.json-number { color: #1d4ed8; }
.json-boolean { color: #be185d; }
.json-null { color: #6b7280; }
.json-index { color: var(--color-text-muted); }
.json-bracket { color: var(--color-text-muted); }
.json-count {
  color: var(--color-text-muted);
  font-size: 0.8rem;
  margin-left: 0.3rem;
}

.json-highlight {
  background: #fde68a;
  border-radius: 2px;
}

.json-collapsed > ul {
  display: none;
}

pre.json-raw {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem;
  overflow: auto;
  max-height: 70vh;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.86rem;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ---------- Word viewer ---------- */

.docx-view {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 2rem;
  max-height: 75vh;
  overflow: auto;
}

.docx-view table {
  border-collapse: collapse;
  margin: 0.6rem 0;
}

.docx-view table td,
.docx-view table th {
  border: 1px solid #ccc;
  padding: 0.3rem 0.5rem;
}

.docx-view img {
  border: 1px dashed var(--color-border);
}

/* ---------- ZIP viewer ---------- */

.zip-layout {
  display: grid;
  grid-template-columns: minmax(220px, 320px) 1fr;
  gap: 1rem;
  align-items: start;
}

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

.zip-tree {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.8rem;
  max-height: 70vh;
  overflow: auto;
  font-size: 0.86rem;
}

.zip-tree ul {
  list-style: none;
  margin: 0;
  padding-left: 1.1rem;
}

.zip-tree > ul {
  padding-left: 0;
}

.zip-tree summary {
  cursor: pointer;
  padding: 0.15rem 0;
  font-weight: 600;
}

.zip-tree .zip-file {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.18rem 0.3rem;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
}

.zip-tree .zip-file:hover {
  background: #eef6ff;
}

.zip-tree .zip-file.active {
  background: var(--color-primary);
  color: #fff;
}

.zip-tree .zip-size {
  color: var(--color-text-muted);
  font-size: 0.78rem;
  flex-shrink: 0;
}

.zip-tree .zip-file.active .zip-size {
  color: #e0ecff;
}

.zip-preview {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem;
  min-height: 200px;
  max-height: 70vh;
  overflow: auto;
}

.zip-preview pre {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.85rem;
  margin: 0;
}

.zip-preview-header {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.6rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--color-border);
}

.zip-preview-header .name {
  font-weight: 600;
  word-break: break-all;
}

.placeholder {
  color: var(--color-text-muted);
  text-align: center;
  padding: 2.5rem 1rem;
}

/* ---------- PDF viewer ---------- */

.pdf-canvas-wrap {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem;
  overflow: auto;
  max-height: 75vh;
}

.pdf-canvas-wrap canvas {
  max-width: 100%;
  height: auto;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.12);
}

.pdf-page-indicator {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.pdf-page-indicator input[type="number"] {
  width: 3.6rem;
  padding: 0.3rem 0.4rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 0.9rem;
  text-align: center;
}

#zoomLevel {
  font-size: 0.88rem;
  color: var(--color-text-muted);
  min-width: 3.2rem;
  text-align: center;
}

/* ---------- Home page ---------- */

.hero {
  text-align: center;
  padding: 2.2rem 1rem 1.4rem;
}

.hero h1 {
  font-size: 1.9rem;
  margin: 0 0 0.5rem;
}

.hero p {
  color: var(--color-text-muted);
  max-width: 640px;
  margin: 0 auto;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin: 1.6rem 0;
}

.tool-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.4rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  transition: box-shadow 0.15s, transform 0.15s;
}

.tool-card:hover {
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08);
  transform: translateY(-2px);
  text-decoration: none;
}

.tool-card .tool-icon {
  font-size: 1.8rem;
}

.tool-card h2 {
  margin: 0;
  font-size: 1.15rem;
  color: var(--color-text);
}

.tool-card p {
  margin: 0;
  font-size: 0.88rem;
  color: var(--color-text-muted);
}

.tool-card .tool-ext {
  font-size: 0.78rem;
  color: var(--color-accent);
  font-family: Consolas, monospace;
}

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.8rem;
  margin: 1.6rem 0;
}

.feature {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem;
  font-size: 0.88rem;
}

.feature strong {
  display: block;
  margin-bottom: 0.2rem;
}

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--color-border);
  padding: 1.2rem;
  text-align: center;
  font-size: 0.82rem;
  color: var(--color-text-muted);
}

.site-footer p {
  margin: 0.2rem 0;
}

/* ---------- Misc ---------- */

.error-box {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--color-danger);
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.hidden {
  display: none !important;
}

@media (max-width: 600px) {
  .header-inner {
    flex-direction: column;
    align-items: flex-start;
  }
  .tool-nav {
    width: 100%;
  }
  .dropzone {
    padding: 1.6rem 0.8rem;
  }
  .docx-view {
    padding: 1rem;
  }
  .pdf-canvas-wrap {
    padding: 0.6rem;
  }
}
