/* ==========================================================================
   DYNAMICWORK DESIGN SYSTEM TOKENS (REBRAND 2026) — OCR Clipboard Studio
   Proprietary Interface of Dynamicwork Co., Ltd.
   Visual Experience Studio — Clarity in Motion
   ========================================================================== */

:root {
  --dw-black: #0E0E0E;
  --dw-graphite: #1A1A1A;
  --dw-surface-deep: #141414;
  --dw-steel-gray: #707070;
  --dw-soft-gray: #B8B8B8;
  --dw-white: #F5F5F5;
  --dw-orange: #E3791D;
  --dw-orange-bright: #F08A30;
  --dw-green: #004A2A;
  --dw-green-light: #0C6B43;
  --dw-emerald: #10B981;
  --dw-danger: #EF4444;

  --dw-border-subtle: rgba(245, 245, 245, 0.08);
  --dw-border-line: rgba(245, 245, 245, 0.14);
  --dw-border-hover-glow: rgba(227, 121, 29, 0.32);
  --dw-border-active: #E3791D;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 22px;

  --max-width: 1560px;
  --font-primary: 'Prompt', system-ui, -apple-system, sans-serif;
  --font-tech: 'Sora', monospace, sans-serif;

  --ease-dw: cubic-bezier(0.4, 0.0, 0.2, 1.0);
  --dur-hover: 0.2s;

  --shadow-01: 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-02: 0 6px 24px rgba(0, 0, 0, 0.45);
  --shadow-03: 0 14px 44px rgba(0, 0, 0, 0.7);
}

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

body {
  background-color: var(--dw-black);
  background-image:
    radial-gradient(circle at 12% 10%, rgba(0, 74, 42, 0.30), transparent 38%),
    radial-gradient(circle at 88% 8%, rgba(227, 121, 29, 0.10), transparent 32%),
    radial-gradient(circle at 50% 94%, rgba(0, 74, 42, 0.18), transparent 45%);
  background-attachment: fixed;
  color: var(--dw-white);
  font-family: var(--font-primary);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

.hidden {
  display: none !important;
}

kbd {
  display: inline-block;
  padding: 1px 6px;
  font-family: var(--font-tech);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--dw-orange-bright);
  background: rgba(227, 121, 29, 0.14);
  border: 1px solid rgba(227, 121, 29, 0.35);
  border-radius: 4px;
}

/* ==========================================================================
   TOP BRAND HEADER
   ========================================================================== */

.top-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(14, 14, 14, 0.92);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--dw-border-subtle);
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 12px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.brand-identity {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo-wrap {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--dw-border-line);
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-logo-wrap svg {
  width: 100%;
  height: 100%;
}

.brand-titles {
  display: flex;
  flex-direction: column;
}

.brand-eyebrow {
  font-family: var(--font-tech);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dw-orange-bright);
  font-weight: 600;
}

.brand-main-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--dw-white);
  line-height: 1.25;
}

.brand-sub-tagline {
  font-size: 12px;
  color: var(--dw-soft-gray);
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.tech-badge {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--dw-border-line);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  display: flex;
  flex-direction: column;
}

.tech-badge span {
  font-family: var(--font-tech);
  font-size: 9.5px;
  color: var(--dw-steel-gray);
  letter-spacing: 0.06em;
}

.tech-badge strong {
  font-size: 12px;
  color: var(--dw-white);
}

.tech-badge.accent {
  border-color: rgba(227, 121, 29, 0.35);
  background: rgba(227, 121, 29, 0.07);
}

.tech-badge.accent strong {
  color: var(--dw-orange-bright);
}

.api-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--dw-steel-gray);
  margin-left: 4px;
}

.api-dot.configured {
  background: var(--dw-emerald);
  box-shadow: 0 0 8px var(--dw-emerald);
}

/* ==========================================================================
   WORKSPACE & TOP SETTINGS BAR
   ========================================================================== */

.workspace-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 16px 28px 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.settings-bar {
  background: rgba(26, 26, 26, 0.88);
  border: 1px solid var(--dw-border-line);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  box-shadow: var(--shadow-01);
}

.settings-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.settings-label {
  font-weight: 600;
  font-size: 13px;
  color: var(--dw-soft-gray);
}

.segmented-control {
  display: inline-flex;
  background: var(--dw-surface-deep);
  border: 1px solid var(--dw-border-line);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 4px;
}

.seg-btn {
  background: transparent;
  color: var(--dw-soft-gray);
  border: none;
  padding: 5px 12px;
  border-radius: 4px;
  font-family: var(--font-primary);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--dur-hover) var(--ease-dw);
}

.seg-btn:hover {
  color: var(--dw-white);
}

.seg-btn.active {
  background: linear-gradient(135deg, var(--dw-orange), #C9600E);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(227, 121, 29, 0.35);
}

.field-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--dw-soft-gray);
}

.studio-select,
.studio-input {
  background: var(--dw-surface-deep);
  color: var(--dw-white);
  border: 1px solid var(--dw-border-line);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-family: var(--font-primary);
  font-size: 12.5px;
  outline: none;
  transition: border-color 0.2s;
}

.studio-select:focus,
.studio-input:focus {
  border-color: var(--dw-orange);
}

.select-sm {
  padding: 4px 8px;
  font-size: 12px;
}

.checkbox-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--dw-border-line);
  border-radius: 999px;
  font-size: 12px;
  color: var(--dw-white);
  cursor: pointer;
  user-select: none;
  transition: all 0.2s;
}

.checkbox-pill:hover {
  border-color: rgba(227, 121, 29, 0.45);
  background: rgba(227, 121, 29, 0.08);
}

.checkbox-pill input[type="checkbox"] {
  accent-color: var(--dw-orange);
  width: 14px;
  height: 14px;
  cursor: pointer;
}

/* ==========================================================================
   MAIN 2-COLUMN SPLIT GRID
   ========================================================================== */

.studio-split-grid {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 18px;
  align-items: stretch;
}

@media (max-width: 1120px) {
  .studio-split-grid {
    grid-template-columns: 1fr;
  }
}

.panel-card {
  background: rgba(26, 26, 26, 0.92);
  border: 1px solid var(--dw-border-line);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-02);
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--dw-border-subtle);
  padding-bottom: 10px;
}

.panel-step-tag {
  font-family: var(--font-tech);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--dw-orange-bright);
  text-transform: uppercase;
}

.panel-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--dw-white);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ==========================================================================
   BUTTONS
   ========================================================================== */

.btn-primary,
.btn-secondary,
.btn-ghost {
  font-family: var(--font-primary);
  font-size: 13px;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all var(--dur-hover) var(--ease-dw);
  border: 1px solid transparent;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--dw-orange), #C85E0C);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 3px 12px rgba(227, 121, 29, 0.3);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--dw-orange-bright), var(--dw-orange));
  transform: translateY(-1px);
  box-shadow: 0 5px 16px rgba(227, 121, 29, 0.45);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--dw-white);
  border-color: var(--dw-border-line);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.11);
  border-color: rgba(227, 121, 29, 0.45);
}

.btn-ghost {
  background: transparent;
  color: var(--dw-soft-gray);
  border-color: transparent;
}

.btn-ghost:hover:not(:disabled) {
  color: var(--dw-white);
  background: rgba(255, 255, 255, 0.05);
}

.btn-ghost.danger-hover:hover:not(:disabled) {
  color: #FCA5A5;
  background: rgba(239, 68, 68, 0.12);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  transform: none !important;
}

/* ==========================================================================
   LEFT PANEL: INTERACTIVE CANVAS & CROP STAGE
   ========================================================================== */

.canvas-stage-wrapper {
  position: relative;
  min-height: 410px;
  max-height: 520px;
  background:
    linear-gradient(45deg, #121212 25%, transparent 25%),
    linear-gradient(-45deg, #121212 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #121212 75%),
    linear-gradient(-45deg, transparent 75%, #121212 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-color: #171717;
  border: 1.5px dashed var(--dw-border-line);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.canvas-stage-wrapper.drag-over {
  border-color: var(--dw-orange);
  box-shadow: inset 0 0 28px rgba(227, 121, 29, 0.22);
}

.empty-stage-overlay {
  text-align: center;
  padding: 32px 24px;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.empty-icon-circle {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(227, 121, 29, 0.12);
  border: 1px solid rgba(227, 121, 29, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin-bottom: 4px;
}

.empty-stage-overlay h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--dw-white);
}

.empty-stage-overlay p {
  font-size: 13px;
  color: var(--dw-soft-gray);
  line-height: 1.6;
}

.empty-cta-row {
  display: flex;
  gap: 10px;
  margin-top: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.canvas-viewport {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  overflow: auto;
}

.canvas-container {
  position: relative;
  display: inline-block;
  line-height: 0;
  cursor: crosshair;
  user-select: none;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.65);
}

#imageCanvas {
  max-width: 100%;
  max-height: 480px;
  width: auto;
  height: auto;
  display: block;
  border-radius: 4px;
}

/* Interactive Crop Box Overlay */
.crop-box {
  position: absolute;
  border: 2px solid var(--dw-orange-bright);
  background: rgba(227, 121, 29, 0.12);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.58);
  pointer-events: none;
  z-index: 10;
}

.crop-dimensions-badge {
  position: absolute;
  top: -24px;
  left: 0;
  background: var(--dw-orange);
  color: #fff;
  font-family: var(--font-tech);
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  white-space: nowrap;
  line-height: 1.3;
}

.canvas-Bottom-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 4px;
}

.crop-info-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--dw-soft-gray);
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--dw-steel-gray);
}

.status-dot.ready {
  background: var(--dw-emerald);
  box-shadow: 0 0 8px var(--dw-emerald);
}

.status-dot.cropped {
  background: var(--dw-orange-bright);
  box-shadow: 0 0 8px var(--dw-orange-bright);
}

.crop-action-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* OCR Progress Bar */
.ocr-progress-wrap {
  background: rgba(20, 20, 20, 0.9);
  border: 1px solid rgba(227, 121, 29, 0.35);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ocr-progress-info {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--dw-white);
}

.ocr-progress-track {
  width: 100%;
  height: 7px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

.ocr-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--dw-green-light), var(--dw-orange-bright));
  border-radius: 999px;
  transition: width 0.18s ease;
}

/* ==========================================================================
   RIGHT PANEL: TEXT EDITOR & TOOLBAR
   ========================================================================== */

.text-stats-badge {
  font-family: var(--font-tech);
  font-size: 11.5px;
  color: var(--dw-orange-bright);
  background: rgba(227, 121, 29, 0.12);
  border: 1px solid rgba(227, 121, 29, 0.3);
  padding: 3px 10px;
  border-radius: 999px;
}

.text-editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.toolbar-left,
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.textarea-wrapper {
  flex: 1;
  display: flex;
  min-height: 360px;
}

.ocr-textarea {
  width: 100%;
  min-height: 360px;
  background: var(--dw-surface-deep);
  color: var(--dw-white);
  border: 1px solid var(--dw-border-line);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-family: var(--font-primary);
  font-size: 14.5px;
  line-height: 1.7;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
}

.ocr-textarea:focus {
  border-color: var(--dw-orange);
  box-shadow: 0 0 0 2px rgba(227, 121, 29, 0.15);
}

.text-panel-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 4px;
}

.footer-hint {
  font-size: 12px;
  color: var(--dw-soft-gray);
}

.footer-btns {
  display: flex;
  gap: 8px;
}

/* ==========================================================================
   BOTTOM SECTION: HISTORY GRID
   ========================================================================== */

.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 12px;
}

.history-empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 24px;
  color: var(--dw-steel-gray);
  background: rgba(255, 255, 255, 0.02);
  border: 1px dashed var(--dw-border-subtle);
  border-radius: var(--radius-md);
  font-size: 13px;
}

.history-card {
  background: var(--dw-surface-deep);
  border: 1px solid var(--dw-border-line);
  border-radius: var(--radius-md);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.2s, transform 0.2s;
}

.history-card:hover {
  border-color: rgba(227, 121, 29, 0.45);
  transform: translateY(-2px);
}

.history-card-top {
  display: flex;
  gap: 10px;
  align-items: center;
}

.history-thumb {
  width: 68px;
  height: 52px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--dw-border-line);
  background: #000;
  flex-shrink: 0;
  cursor: pointer;
}

.history-meta {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.history-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.history-index {
  font-family: var(--font-tech);
  font-size: 11px;
  font-weight: 700;
  color: var(--dw-orange-bright);
}

.history-engine-tag {
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--dw-soft-gray);
}

.history-time {
  font-size: 11px;
  color: var(--dw-steel-gray);
}

.history-snippet {
  font-size: 12.5px;
  color: var(--dw-white);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--dw-border-subtle);
  border-radius: 6px;
  padding: 6px 8px;
  height: 60px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  white-space: pre-wrap;
  word-break: break-word;
}

.history-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

/* ==========================================================================
   MODAL & TOAST
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-card {
  width: 100%;
  max-width: 520px;
  background: var(--dw-graphite);
  border: 1px solid var(--dw-border-line);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow-03);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 1px solid var(--dw-border-subtle);
  padding-bottom: 10px;
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-desc {
  font-size: 13px;
  color: var(--dw-soft-gray);
  line-height: 1.6;
}

.modal-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12.5px;
  color: var(--dw-white);
}

.modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 8px;
  border-top: 1px solid var(--dw-border-subtle);
}

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast-item {
  background: rgba(20, 20, 20, 0.96);
  border-left: 4px solid var(--dw-orange);
  border-top: 1px solid var(--dw-border-line);
  border-right: 1px solid var(--dw-border-line);
  border-bottom: 1px solid var(--dw-border-line);
  color: var(--dw-white);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-02);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toastSlideIn 0.22s ease;
}

.toast-item.success {
  border-left-color: var(--dw-emerald);
}

.toast-item.error {
  border-left-color: var(--dw-danger);
}

@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
