/* Minimal monochrome theme. Fonts are loaded via <link> in the HTML, not a render-blocking @import */

:root {
  color-scheme: light;
  --bg-primary: #ffffff;
  --bg-card: #ffffff;
  --bg-modal: #ffffff;
  --bg-subtle: #f5f5f5;

  /* Accent is the ink colour: black on light, white on dark */
  --accent-primary: #0a0a0a;
  --on-accent: #ffffff;
  --dot-color: #b5b5b5;

  --text-primary: #0a0a0a;
  --text-secondary: #525252;
  --text-muted: #8a8a8a;

  --border-color: #e5e5e5;
  --border-focus: #0a0a0a;

  --radius: 4px;
  --transition-smooth: all 0.2s ease;

  --font-display: 'Inter Tight', 'Inter', system-ui, -apple-system, sans-serif;

  --bg-icon-btn: transparent;
  --bg-icon-btn-hover: #f5f5f5;
  --bg-dropzone: #ffffff;
  --bg-text-box: #fafafa;
  --border-text-box: #e5e5e5;
  --bg-toast: #0a0a0a;
  --text-toast: #ffffff;
  --bg-input: #ffffff;
  --scrollbar-thumb: #d4d4d4;
  --text-warning: #b91c1c;
  --border-warning: #fecaca;
  --danger: #dc2626;
}

:root.dark-mode {
  color-scheme: dark;
  --bg-primary: #0a0a0a;
  --bg-card: #0a0a0a;
  --bg-modal: #111111;
  --bg-subtle: #171717;

  --accent-primary: #fafafa;
  --on-accent: #0a0a0a;
  --dot-color: #555555;

  --text-primary: #fafafa;
  --text-secondary: #a3a3a3;
  --text-muted: #737373;

  --border-color: #262626;
  --border-focus: #fafafa;

  --bg-icon-btn: transparent;
  --bg-icon-btn-hover: #171717;
  --bg-dropzone: #0a0a0a;
  --bg-text-box: #111111;
  --border-text-box: #262626;
  --bg-toast: #fafafa;
  --text-toast: #0a0a0a;
  --bg-input: #0a0a0a;
  --scrollbar-thumb: #333333;
  --text-warning: #fca5a5;
  --border-warning: #7f1d1d;
  --danger: #f87171;
}

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

html {
  background-color: var(--bg-primary);
}

body {
  visibility: visible; /* revealed once this stylesheet applies (hidden by the inline style in <head>) */
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: 100dvh; /* excludes mobile browser toolbars */
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

svg {
  flex-shrink: 0;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 999px;
}

/* Glow element kept in the markup but no longer drawn */
.ambient-glow-1 {
  display: none;
}

.app-container {
  width: 100%;
  max-width: 640px;
  /* Keep content clear of the notch / home indicator in standalone mode */
  padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  gap: 20px;
  z-index: 1;
}

/* Header: plain bar, no card */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
}

.header-actions {
  display: flex;
  gap: 4px;
  align-items: center;
}

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

.logo-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
}

.wordmark {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.icon-btn {
  background: var(--bg-icon-btn);
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--text-primary);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

@media (hover: hover) {
  .icon-btn:hover {
    background: var(--bg-icon-btn-hover);
  }
}

/* Hero */
.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 20px;
  padding: 28px 0 8px;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-primary);
}

.hero-badge svg {
  width: 14px;
  height: 14px;
}

.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2.6rem, 11vw, 4.5rem);
  font-weight: 800;
  line-height: 0.95;
  letter-spacing: -0.035em;
  text-transform: uppercase;
  color: var(--text-primary);
}

.hero h1 .dot {
  color: var(--dot-color);
}

.hero-sub {
  font-size: 1.02rem;
  line-height: 1.55;
  color: var(--text-secondary);
  max-width: 34ch;
}

/* API Banner (If API key is missing) */
.api-warning-banner {
  border: 1px solid var(--border-warning);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  text-align: center;
  animation: fadeIn 0.3s ease-out;
}

.api-warning-banner svg {
  width: 24px;
  height: 24px;
  color: var(--danger);
}

.api-warning-banner p {
  font-size: 0.875rem;
  color: var(--text-warning);
  line-height: 1.5;
}

.btn-warning {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--text-primary);
  min-height: 44px;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: var(--transition-smooth);
}

@media (hover: hover) {
  .btn-warning:hover {
    background: var(--text-primary);
    color: var(--bg-primary);
  }
}

/* Upload / Camera area */
.upload-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
}

.dropzone {
  border: 1px dashed var(--scrollbar-thumb);
  border-radius: var(--radius);
  padding: 40px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  transition: var(--transition-smooth);
  background: var(--bg-dropzone);
  text-align: center;
}

.dropzone.dragover,
.dropzone:focus-visible {
  border-color: var(--text-primary);
  border-style: solid;
  background: var(--bg-subtle);
}

@media (hover: hover) {
  .dropzone:hover {
    border-color: var(--text-primary);
  }
}

.dropzone svg {
  width: 32px;
  height: 32px;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.dropzone span {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-primary);
}

.dropzone .dropzone-subtext,
.dropzone .dropzone-subtext span {
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--text-muted);
}

.hidden-input {
  display: none;
}

/* Image Preview Container */
.preview-container {
  display: none;
  position: relative;
  width: 100%;
  max-height: 320px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.preview-img {
  width: 100%;
  height: 100%;
  max-height: 320px;
  object-fit: contain;
  background: var(--bg-subtle);
  display: block;
}

.clear-preview-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  cursor: pointer;
  transition: var(--transition-smooth);
}

.clear-preview-btn svg {
  width: 18px;
  height: 18px;
}

@media (hover: hover) {
  .clear-preview-btn:hover {
    border-color: var(--text-primary);
  }
}

/* Primary Translation Control */
.control-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: stretch;
}

.btn-translate,
.btn-primary {
  background: var(--accent-primary);
  border: 1px solid var(--accent-primary);
  border-radius: var(--radius);
  color: var(--on-accent);
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  min-height: 52px;
  padding: 14px 24px;
  cursor: pointer;
  transition: var(--transition-smooth);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.btn-translate svg,
.btn-primary svg {
  width: 16px;
  height: 16px;
}

@media (hover: hover) {
  .btn-translate:hover:not(:disabled),
  .btn-primary:hover:not(:disabled) {
    opacity: 0.85;
  }
}

.btn-translate:disabled,
.btn-primary:disabled {
  cursor: not-allowed;
  background: var(--bg-subtle);
  border-color: var(--border-color);
  color: var(--text-muted);
}

.btn-camera {
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-primary);
  width: 52px;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-smooth);
}

@media (hover: hover) {
  .btn-camera:hover {
    border-color: var(--text-primary);
  }
}

.btn-camera svg {
  width: 22px;
  height: 22px;
}

/* Spinner */
.spinner {
  width: 16px;
  height: 16px;
  border: 1.5px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: none;
}

/* Camera Overlay */
.camera-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  background: #000;
  z-index: 1000;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
}

.camera-preview {
  width: 100%;
  height: calc(100% - 150px);
  object-fit: cover;
  border-radius: var(--radius);
  background: #111;
}

.camera-controls {
  width: 100%;
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding-bottom: 20px;
}

.shutter-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: #fff;
  border: 4px solid #000;
  outline: 2px solid #fff;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.shutter-btn:active {
  transform: scale(0.92);
}

.close-camera-btn {
  align-self: flex-start;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: var(--radius);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  cursor: pointer;
}

.close-camera-btn svg {
  width: 20px;
  height: 20px;
}

/* Results section */
.results-section {
  display: none;
  flex-direction: column;
  gap: 12px;
  animation: fadeIn 0.3s ease-out;
}

.result-card,
.history-section {
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg-card);
}

.result-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.result-title {
  font-family: 'Inter', sans-serif;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-primary);
  font-weight: 600;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  margin-left: auto;
}

.btn-small {
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-primary);
  min-height: 40px;
  padding: 6px 12px;
  font-size: 0.75rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  cursor: pointer;
  transition: var(--transition-smooth);
}

@media (hover: hover) {
  .btn-small:hover {
    border-color: var(--text-primary);
  }
}

.btn-small svg {
  width: 15px;
  height: 15px;
}

.text-box {
  width: 100%;
  min-height: 100px;
  background: var(--bg-text-box);
  border: 1px solid var(--border-text-box);
  border-radius: var(--radius);
  padding: 12px;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-primary);
  resize: none;
  overflow-y: hidden;
  outline: none;
}

.text-box:focus {
  border-color: var(--text-primary);
}

.text-box.malayalam {
  font-family: 'Noto Sans Malayalam', sans-serif;
}

/* History Section */
.history-header {
  min-height: 40px;
  background: none;
  border: none;
  color: inherit;
  font: inherit;
  width: 100%;
  text-align: left;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}

.history-header > svg {
  width: 18px;
  height: 18px;
  color: var(--text-secondary);
  transition: transform 0.2s ease;
}

.history-title {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 10px;
}

.history-title svg {
  width: 16px;
  height: 16px;
}

.history-list {
  display: flex;
  flex-direction: column;
  max-height: 280px;
  overflow-y: auto;
}

.history-item {
  border-top: 1px solid var(--border-color);
  padding: 10px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.history-text-wrapper {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex-grow: 1;
  min-width: 0;
  overflow: hidden;
  /* reset <button> defaults */
  background: none;
  border: none;
  padding: 2px 0;
  margin: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  border-radius: 2px;
}

.history-text-wrapper > span {
  display: block;
}

@media (hover: hover) {
  .history-text-wrapper:hover .history-item-eng {
    text-decoration: underline;
    text-underline-offset: 3px;
  }
}

.history-item-mal {
  font-family: 'Noto Sans Malayalam', sans-serif;
  font-size: 0.85rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item-eng {
  font-size: 0.92rem;
  color: var(--text-primary);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item-date {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.history-actions {
  display: flex;
  gap: 6px;
}

.btn-delete-history {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
}

@media (hover: hover) {
  .btn-delete-history:hover {
    color: var(--danger);
    background: var(--bg-subtle);
  }
}

.btn-delete-history svg {
  width: 16px;
  height: 16px;
}

.empty-history {
  border-top: 1px solid var(--border-color);
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 16px 0 4px;
}

/* Settings Modal */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  background: rgba(0, 0, 0, 0.4);
  z-index: 100;
  justify-content: center;
  align-items: center;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  overflow-y: auto;
}

.modal-content {
  background: var(--bg-modal);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  width: 100%;
  max-width: 440px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-height: 100%;
  overflow-y: auto;
  animation: fadeIn 0.2s ease-out;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-close-btn svg {
  width: 20px;
  height: 20px;
}

.modal-title {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-transform: uppercase;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-primary);
}

.api-key-container {
  display: flex;
  position: relative;
  align-items: center;
}

.input-text {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-primary);
  padding: 12px 48px 12px 14px;
  font-size: 0.95rem;
  outline: none;
  transition: var(--transition-smooth);
}

.input-text:focus {
  border-color: var(--text-primary);
}

.toggle-pwd-btn {
  position: absolute;
  right: 0;
  width: 44px;
  height: 44px;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
}

.toggle-pwd-btn svg {
  width: 18px;
  height: 18px;
}

.select-model {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-primary);
  padding: 12px 14px;
  font-size: 0.95rem;
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23888' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px;
  transition: var(--transition-smooth);
}

.select-model:focus {
  border-color: var(--text-primary);
}

.form-help {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.form-help a {
  color: var(--text-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* First-visit Consent Dialog */
.consent-overlay {
  z-index: 200;
}

.consent-heading {
  display: flex;
  align-items: center;
  gap: 12px;
}

.consent-text {
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

.consent-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text-primary);
  cursor: pointer;
}

.consent-check input {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--accent-primary);
  cursor: pointer;
}

.consent-check a {
  color: var(--text-primary);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom));
  left: 50%;
  width: max-content; /* otherwise left: 50% squeezes long messages to half the screen */
  max-width: calc(100% - 32px);
  transform: translateX(-50%) translateY(calc(100px + env(safe-area-inset-bottom)));
  background: var(--bg-toast);
  border-radius: var(--radius);
  padding: 12px 18px;
  color: var(--text-toast);
  font-size: 0.875rem;
  font-weight: 500;
  transition: transform 0.25s ease, opacity 0.25s ease;
  opacity: 0;
  z-index: 2000;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 10px;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast-icon {
  display: none;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
}

.toast.toast-success .toast-icon-success,
.toast.toast-info .toast-icon-info { display: block; }
.toast.toast-error .toast-icon-error { display: block; color: var(--danger); }

.toast.has-action {
  pointer-events: auto;
}

.toast-action {
  margin-left: 6px;
  min-height: 36px;
  padding: 6px 12px;
  border: 1px solid currentColor;
  border-radius: var(--radius);
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

/* Keyboard focus (mouse/touch clicks don't show the ring) */
:where(button, a, [role="button"], select, input, textarea, .history-text-wrapper):focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
}

/* Animations */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

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

/* Crop button on the image preview */
.edit-preview-btn {
  position: absolute;
  left: 10px;
  bottom: 10px;
  min-height: 40px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-primary);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.edit-preview-btn svg {
  width: 16px;
  height: 16px;
}

@media (hover: hover) {
  .edit-preview-btn:hover {
    border-color: var(--text-primary);
  }
}

/* Ctrl+V hint only makes sense with a keyboard */
@media (pointer: coarse) {
  .paste-hint {
    display: none;
  }
}

.share-btn[hidden] {
  display: none;
}

/* Crop / rotate editor */
.crop-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  flex-direction: column;
  background: #000;
  color: #fff;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  touch-action: none;
}

.crop-overlay.open {
  display: flex;
}

.crop-toolbar,
.crop-actions {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
}

.crop-actions {
  justify-content: center;
  gap: 24px;
  padding-bottom: 16px;
}

.crop-title {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin: 0;
}

.crop-text-btn,
.crop-tool-btn {
  min-height: 44px;
  min-width: 44px;
  padding: 0 14px;
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: transparent;
  color: #fff;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.crop-text-btn.crop-done {
  background: #fff;
  color: #000;
  border-color: #fff;
}

.crop-tool-btn svg {
  width: 20px;
  height: 20px;
}

.crop-stage {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow: hidden;
}

.crop-frame {
  position: relative;
  line-height: 0;
}

.crop-canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
}

.crop-box {
  position: absolute;
  border: 1px solid #fff;
  /* Darken everything outside the crop area */
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.6);
  cursor: move;
  touch-action: none;
  outline: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.3)),
    linear-gradient(rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.3)),
    linear-gradient(rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.3)),
    linear-gradient(rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.3));
  background-size: 1px 100%, 1px 100%, 100% 1px, 100% 1px;
  background-position: 33.33% 0, 66.66% 0, 0 33.33%, 0 66.66%;
  background-repeat: no-repeat;
}

.crop-box:focus-visible {
  border-width: 2px;
}

/* Visible corner marks with a larger invisible touch area */
.crop-handle {
  position: absolute;
  width: 44px;
  height: 44px;
  touch-action: none;
}

.crop-handle::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border: 3px solid #fff;
}

.crop-handle[data-handle="nw"] { top: -22px; left: -22px; cursor: nwse-resize; }
.crop-handle[data-handle="ne"] { top: -22px; right: -22px; cursor: nesw-resize; }
.crop-handle[data-handle="sw"] { bottom: -22px; left: -22px; cursor: nesw-resize; }
.crop-handle[data-handle="se"] { bottom: -22px; right: -22px; cursor: nwse-resize; }

.crop-handle[data-handle="nw"]::after { top: 19px; left: 19px; border-right: 0; border-bottom: 0; }
.crop-handle[data-handle="ne"]::after { top: 19px; right: 19px; border-left: 0; border-bottom: 0; }
.crop-handle[data-handle="sw"]::after { bottom: 19px; left: 19px; border-right: 0; border-top: 0; }
.crop-handle[data-handle="se"]::after { bottom: 19px; right: 19px; border-left: 0; border-top: 0; }

/* Desktop */
@media (min-width: 640px) {
  .app-container {
    padding: max(20px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(32px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
    gap: 24px;
  }
  .hero {
    padding: 56px 0 16px;
    gap: 24px;
  }
  .result-card,
  .history-section {
    padding: 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
