.app {
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 16px;
  gap: 12px;
}

.sidebar-header h1 {
  margin: 0;
  font-size: 1.25rem;
  color: var(--color-gold);
}

.sidebar-header p {
  margin: 4px 0 0;
  font-size: 0.85rem;
  color: #999;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.875rem;
  cursor: pointer;
  font-weight: 600;
}

.btn-primary {
  background: var(--color-gold);
  color: #1a1a1a;
}

.btn-primary:hover {
  background: var(--color-gold-light);
}

.btn-secondary {
  background: #333;
  color: #eee;
}

.btn-secondary:hover {
  background: #444;
}

.toolbar-export {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.toolbar-export .btn {
  width: 100%;
  padding: 8px 10px;
  font-size: 0.8rem;
}

.field-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.text-input {
  flex: 1;
  min-height: 200px;
  resize: vertical;
  border: 1px solid #444;
  border-radius: 8px;
  background: #2a2a2a;
  color: #eee;
  padding: 12px;
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 0.8rem;
  line-height: 1.5;
}

.text-input:focus {
  outline: 2px solid var(--color-gold);
  border-color: transparent;
}

.table-input {
  width: 100%;
  min-height: 120px;
  max-height: 220px;
  resize: vertical;
  border: 1px solid #444;
  border-radius: 8px;
  background: #2a2a2a;
  color: #eee;
  padding: 10px;
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 0.75rem;
  line-height: 1.45;
  margin-bottom: 8px;
}

.table-input:focus {
  outline: 2px solid var(--color-gold);
  border-color: transparent;
}

.btn-block {
  width: 100%;
}

.settings-panel {
  border: 1px solid #333;
  border-radius: 8px;
  padding: 10px 12px;
  background: #252525;
}

.settings-panel summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--color-gold);
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.settings-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.75rem;
  color: #aaa;
}

.settings-grid input[type="color"] {
  width: 100%;
  height: 32px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  padding: 2px;
}

.settings-grid input[type="text"],
.settings-grid input[type="number"] {
  background: #2a2a2a;
  border: 1px solid #444;
  border-radius: 6px;
  color: #eee;
  padding: 6px 8px;
  font-size: 0.85rem;
}

.settings-grid label:has(input[type="text"]),
.settings-grid label.full-width {
  grid-column: 1 / -1;
}

.settings-grid select {
  background: #2a2a2a;
  border: 1px solid #444;
  border-radius: 6px;
  color: #eee;
  padding: 6px 8px;
  font-size: 0.85rem;
}

.hint {
  font-size: 0.8rem;
  color: #888;
  margin: 8px 0;
}

.paste-hint {
  margin: 0 0 6px;
}

.image-list {
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
}

.image-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid #333;
  font-size: 0.8rem;
}

.image-list img {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 4px;
}

.help-list {
  margin: 8px 0 0;
  padding-left: 18px;
  font-size: 0.8rem;
  color: #aaa;
  line-height: 1.6;
}

.footer-watermark-settings select {
  background: #2a2a2a;
  border: 1px solid #444;
  border-radius: 6px;
  color: #eee;
  padding: 6px 8px;
  font-size: 0.85rem;
}

.header-toggle,
.footer-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: #ccc;
  margin: 8px 0 12px;
  cursor: pointer;
}

.header-logo-settings {
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid #333;
}

.header-logo-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.header-logo-preview {
  width: 72px;
  height: 72px;
  object-fit: contain;
  background: repeating-conic-gradient(#2a2a2a 0% 25%, #222 0% 50%) 50% / 12px 12px;
  border-radius: 8px;
  padding: 6px;
  flex-shrink: 0;
}

.header-logo-controls {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.header-logo-controls label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.75rem;
  color: #aaa;
}

.header-logo-controls input[type="number"] {
  background: #2a2a2a;
  border: 1px solid #444;
  border-radius: 6px;
  color: #eee;
  padding: 6px 8px;
}

.header-logo-upload-label input[type="file"] {
  font-size: 0.75rem;
  color: #ccc;
}

.header-lines,
.footer-lines {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.header-line-row,
.footer-line-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  padding-bottom: 12px;
  border-bottom: 1px solid #333;
}

.header-line-row:last-child,
.footer-line-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.header-line-row label,
.footer-line-row label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.75rem;
  color: #aaa;
}

.header-line-row label.chk,
.footer-line-row label.chk {
  flex-direction: row;
  align-items: center;
  color: #ccc;
}

.header-line-row input[type="text"],
.footer-line-row input[type="text"] {
  background: #2a2a2a;
  border: 1px solid #444;
  border-radius: 6px;
  color: #eee;
  padding: 6px 8px;
  font-size: 0.85rem;
}

.header-line-row input[type="color"],
.footer-line-row input[type="color"] {
  width: 100%;
  height: 28px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

.header-line-row input[type="number"],
.footer-line-row input[type="number"] {
  background: #2a2a2a;
  border: 1px solid #444;
  border-radius: 6px;
  color: #eee;
  padding: 6px 8px;
  width: 100%;
}

.footer-watermark-settings {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid #333;
}

.footer-watermark-settings label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.75rem;
  color: #aaa;
}

.footer-logo-settings {
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid #333;
}

.footer-logo-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.footer-logo-preview {
  width: 72px;
  height: 72px;
  object-fit: contain;
  background: repeating-conic-gradient(#2a2a2a 0% 25%, #222 0% 50%) 50% / 12px 12px;
  border-radius: 8px;
  padding: 6px;
  flex-shrink: 0;
}

.footer-logo-controls {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.footer-logo-controls label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.75rem;
  color: #aaa;
}

.footer-logo-controls input[type="number"] {
  background: #2a2a2a;
  border: 1px solid #444;
  border-radius: 6px;
  color: #eee;
  padding: 6px 8px;
}

.footer-logo-upload-label input[type="file"] {
  font-size: 0.75rem;
  color: #ccc;
}

.footer-lines {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

@media (min-width: 360px) {
  .header-line-row,
  .footer-line-row {
    grid-template-columns: 1fr 70px 60px auto;
    align-items: end;
  }

  .header-line-row label:first-child,
  .footer-line-row label:first-child {
    grid-column: 1 / -1;
  }
}

.preview-pane {
  display: flex;
  flex-direction: column;
  background: #888;
  overflow: hidden;
}

.preview-label {
  padding: 8px 16px;
  background: #555;
  color: #eee;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.preview-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.preview-root {
  max-width: 720px;
  margin: 0 auto;
}

.print-area {
  display: none;
}

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: 50vh 50vh;
  }
}
