:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --border: #2d3a4f;
  --text: #e8edf4;
  --muted: #8b9cb3;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --success: #22c55e;
  --error: #ef4444;
  --radius: 12px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

.app {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
}

header {
  margin-bottom: 24px;
}

header h1 {
  font-size: 1.75rem;
  font-weight: 700;
}

header p {
  color: var(--muted);
  margin-top: 4px;
}

.secure-hint {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.12);
  color: #fecaca;
  font-size: 0.92rem;
}

.layout {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(480px, 1.4fr);
  gap: 20px;
  align-items: start;
}

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

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

.panel h2 {
  font-size: 1.1rem;
  margin-bottom: 16px;
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.875rem;
  color: var(--muted);
}

select,
textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 0.95rem;
  font-family: inherit;
}

select:focus,
textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.btn-row,
.capture-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.capture-row {
  margin-top: 16px;
}

.btn {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 10px 16px;
  transition: background 0.15s, border-color 0.15s;
}

.btn:hover:not(:disabled) {
  border-color: var(--accent);
}

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

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

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

.btn.large {
  flex: 1;
  padding: 14px 20px;
  font-size: 1rem;
  font-weight: 600;
}

.video-wrap {
  position: relative;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 16 / 9;
}

#video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.status {
  margin-top: 12px;
  font-size: 0.85rem;
  color: var(--muted);
  min-height: 1.25rem;
}

.status.error {
  color: var(--error);
}

.status.success {
  color: var(--success);
}

.preview-wrap {
  margin: 12px 0;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.preview-wrap.hidden {
  display: none;
}

#preview {
  width: 100%;
  display: block;
}

.result {
  background: #fff;
  border: 1px solid #b4b4b4;
  border-radius: 4px;
  min-height: 320px;
  max-height: 620px;
  overflow: auto;
  margin: 12px 0;
  color: #1a1a1a;
  font-family: "Segoe UI", Calibri, Arial, sans-serif;
  font-size: 0.8125rem;
  line-height: 1.4;
  box-shadow: inset 0 0 0 1px #e6e6e6;
}

.result .hint {
  color: #666;
  padding: 24px;
  text-align: center;
}

.result.loading {
  color: #666;
  font-style: italic;
  padding: 24px;
  background: #fafafa;
}

.excel-sheet {
  min-width: 960px;
  background: #fff;
}

.table-edit-hint {
  color: #666;
  font-size: 0.75rem;
  margin-top: 8px;
  font-style: italic;
}

.excel-header-block {
  padding: 16px 18px 10px;
  border-bottom: 1px solid #d9d9d9;
}

.excel-header-row {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 8px;
}

.excel-header-left,
.excel-header-right {
  flex: 1;
}

.excel-header-left p,
.excel-header-right p {
  margin: 2px 0;
  font-size: 0.8125rem;
}

.excel-header-left p:first-child,
.excel-header-right p:first-child {
  font-weight: 700;
  text-transform: uppercase;
}

.excel-header-right {
  text-align: center;
}

.excel-title {
  text-align: center;
  font-size: 1.05rem;
  font-weight: 700;
  margin: 14px 0 10px;
  letter-spacing: 0.02em;
}

.excel-meta-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-size: 0.8125rem;
  margin-bottom: 4px;
}

.excel-table-wrap {
  overflow: auto;
}

.excel-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.excel-table th,
.excel-table td {
  border: 1px solid #bfbfbf;
  padding: 8px 10px;
  vertical-align: top;
  word-wrap: break-word;
}

.excel-table thead th {
  background: #e8edf4;
  color: #1a1a1a;
  font-weight: 700;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 1;
  box-shadow: inset 0 -1px 0 #bfbfbf;
}

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

.excel-table tbody tr:hover {
  background: #f0f6ff;
}

.excel-table .col-stt,
.excel-table .col-page {
  width: 56px;
  text-align: center;
}

.excel-table .col-symbol {
  width: 120px;
}

.excel-table .col-date {
  width: 96px;
  text-align: center;
}

.excel-table .col-summary {
  width: 34%;
}

.excel-table .col-author {
  width: 18%;
}

.excel-table .col-note {
  width: 80px;
}

.excel-table .col-actions {
  width: 44px;
  text-align: center;
}

.excel-table td.col-stt,
.excel-table td.col-date,
.excel-table td.col-actions {
  text-align: center;
}

.excel-table .cell-input {
  width: 100%;
  border: 1px solid #c8c8c8;
  border-radius: 2px;
  background: #fff;
  color: #1a1a1a;
  padding: 4px 6px;
  font-size: 0.8125rem;
  font-family: inherit;
  box-sizing: border-box;
}

.excel-table .cell-input.align-center {
  text-align: center;
}

.excel-table .cell-input.align-left {
  text-align: left;
}

.excel-table .cell-textarea {
  min-height: 56px;
  resize: vertical;
  line-height: 1.35;
  text-align: left;
}

.excel-table .cell-input:focus {
  outline: 2px solid #217346;
  border-color: #217346;
  background: #fffef5;
}

.btn-delete-row {
  width: 28px;
  height: 28px;
  border: 1px solid #e0a0a0;
  border-radius: 4px;
  background: #fff5f5;
  color: #c0392b;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  padding: 0;
}

.btn-delete-row:hover {
  background: #fde8e8;
  border-color: #c0392b;
}

.result.result-plain {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: "Cascadia Code", "Fira Code", monospace;
  font-size: 0.875rem;
  line-height: 1.6;
  padding: 16px;
  white-space: pre-wrap;
  box-shadow: none;
  min-height: 280px;
  max-height: 480px;
}

.result-panel .btn-row {
  margin-top: 8px;
}

.hidden {
  display: none !important;
}

.meta-info {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 12px;
  font-size: 0.875rem;
}

.meta-info p {
  margin: 4px 0;
}

input[type="file"] {
  background: var(--bg);
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--muted);
  padding: 12px;
  font-size: 0.875rem;
}

.hoso-form {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 12px;
  display: grid;
  gap: 10px;
}

.hoso-form h3 {
  font-size: 0.95rem;
  margin-bottom: 2px;
}

input[type="text"] {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 0.95rem;
  font-family: inherit;
}

input[type="text"]:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

#sessionActions {
  margin-bottom: 12px;
}
