:root {
  --bg: #f8fafc;
  --fg: #0f172a;
  --border: #0f172a;
  --shadow: 5px 5px 0px 0px #0f172a;
  --shadow-sm: 3px 3px 0px 0px #0f172a;
  --shadow-active: 2px 2px 0px 0px #0f172a;
  --shadow-hover: 6px 6px 0px 0px #0f172a;
  --radius: 8px;
  --border-question: #8423B1;
  --border-answer: #136EB9;
  --border-selection: #F5B201;
  --bg-question: rgba(132, 35, 177, 0.08);
  --bg-answer: rgba(19, 110, 185, 0.08);
  --bg-selection: rgba(245, 178, 1, 0.08);
  --shadow-question: 3px 3px 0px 0px #8423B1;
  --shadow-question-active: 2px 2px 0px 0px #8423B1;
  --shadow-answer: 3px 3px 0px 0px #136EB9;
  --shadow-answer-active: 2px 2px 0px 0px #136EB9;
  --shadow-selection: 3px 3px 0px 0px #F5B201;
  --shadow-selection-active: 2px 2px 0px 0px #F5B201;
}

body.dark {
  --bg: #111111;
  --fg: #f0f0f0;
  --border: #525252;
  --shadow: 5px 5px 0px 0px #525252;
  --shadow-sm: 3px 3px 0px 0px #525252;
  --shadow-active: 2px 2px 0px 0px #525252;
  --shadow-hover: 6px 6px 0px 0px #525252;
  --border-question: #a78bfa;
  --border-answer: #60a5fa;
  --border-selection: #fbbf24;
  --bg-question: rgba(132, 35, 177, 0.2);
  --bg-answer: rgba(19, 110, 185, 0.2);
  --bg-selection: rgba(251, 191, 36, 0.15);
  --shadow-question: 3px 3px 0px 0px #a78bfa;
  --shadow-question-active: 2px 2px 0px 0px #a78bfa;
  --shadow-answer: 3px 3px 0px 0px #60a5fa;
  --shadow-answer-active: 2px 2px 0px 0px #60a5fa;
  --shadow-selection: 3px 3px 0px 0px #fbbf24;
  --shadow-selection-active: 2px 2px 0px 0px #fbbf24;
}

* {
  font-family: 'Source Code Pro', monospace;
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--fg);
  overflow: hidden;
  font-size: 15px;
  font-weight: 600;
  transition: background 0.2s, color 0.2s;
}

::selection {
  background: #F5B201;
  color: #0f172a;
}

*:focus {
  outline: none;
}

*:focus-visible {
  outline: 3px solid #6366f1;
  outline-offset: 3px;
  border-radius: var(--radius);
}

.logo-light {
  display: block;
}

.logo-dark {
  display: none;
}

body.dark .logo-light {
  display: none;
}

body.dark .logo-dark {
  display: block;
}

.brutal-box {
  background: var(--bg);
  border: 3px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.brutal-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  border: 3px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 12px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
  color: var(--fg);
  background: var(--bg);
  white-space: nowrap;
}

.brutal-btn:hover:not(:disabled) {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
  filter: brightness(1.08);
}

.brutal-btn:active:not(:disabled),
.brutal-btn.active {
  transform: translateY(2px);
  box-shadow: var(--shadow-active);
  filter: brightness(0.95);
}

.brutal-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: var(--shadow-sm);
  filter: none;
}

.col-header .brutal-btn {
  padding: 4px 10px;
  font-size: 11px;
  height: 36px;
}

.btn-violet {
  background: #8423B1 !important;
  color: #ffffff !important;
  border-color: var(--border) !important;
}

.btn-blue {
  background: #136EB9 !important;
  color: #ffffff !important;
  border-color: var(--border) !important;
}

.btn-emerald {
  background: #2B8E2B !important;
  color: #ffffff !important;
  border-color: var(--border) !important;
}

.btn-red {
  background: #EA5252 !important;
  color: #ffffff !important;
  border-color: var(--border) !important;
}

.btn-white {
  background: #ffffff !important;
  color: #0f172a !important;
  border-color: var(--border) !important;
}

.btn-yellow {
  background: #F5B201 !important;
  color: #0f172a !important;
  border-color: var(--border) !important;
}

body.dark .btn-violet,
body.dark .btn-blue,
body.dark .btn-emerald,
body.dark .btn-red {
  border-color: #525252 !important;
}

body.dark .btn-white {
  background: #e2e8f0 !important;
  color: #0f172a !important;
  border-color: #525252 !important;
}

.brutal-input {
  width: 100%;
  padding: 12px;
  background: var(--bg);
  border: 3px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  font-size: 15px;
  font-weight: 600;
  color: var(--fg);
  transition: all 0.15s ease;
}

.brutal-input:focus {
  transform: translate(2px, 2px);
  box-shadow: var(--shadow-active);
}

body.dark .brutal-input {
  background: #1a1a1a;
}

.input-question {
  border-color: var(--border-question) !important;
  background-color: var(--bg-question) !important;
  box-shadow: var(--shadow-question) !important;
}

.input-question:focus {
  background-color: var(--bg-question) !important;
  box-shadow: var(--shadow-question-active) !important;
}

.input-answer {
  border-color: var(--border-answer) !important;
  background-color: var(--bg-answer) !important;
  box-shadow: var(--shadow-answer) !important;
}

.input-answer:focus {
  background-color: var(--bg-answer) !important;
  box-shadow: var(--shadow-answer-active) !important;
}

.input-selection {
  border-color: var(--border-selection) !important;
  background-color: var(--bg-selection) !important;
  box-shadow: var(--shadow-selection) !important;
}

.brutal-label {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.kbd {
  font-family: 'Source Code Pro', monospace;
  background: var(--bg);
  border: 2px solid var(--border);
  border-bottom-width: 3px;
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 800;
  color: var(--fg);
  white-space: nowrap;
  display: inline-block;
}

.key-cap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.95);
  border: 2px solid rgba(0, 0, 0, 0.3);
  border-bottom-width: 4px;
  border-radius: 6px;
  font-size: 22px;
  font-weight: 900;
  color: #0f172a;
  flex-shrink: 0;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
}

.key-cap-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  padding: 2px 8px;
  background: rgba(255, 255, 255, 0.95);
  border: 2px solid rgba(0, 0, 0, 0.3);
  border-bottom-width: 3px;
  border-radius: 5px;
  font-size: 18px;
  font-weight: 900;
  color: #0f172a;
  flex-shrink: 0;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
}

body.dark .key-cap,
body.dark .key-cap-sm {
  background: rgba(30, 41, 59, 0.95);
  border-color: rgba(255, 255, 255, 0.3);
  color: #f0f0f0;
  box-shadow: 0 2px 0 rgba(255, 255, 255, 0.1);
}

.app-grid {
  display: grid;
  grid-template-columns: minmax(400px, 5fr) minmax(300px, 3.5fr) minmax(280px, 3fr);
  grid-template-rows: auto 1fr;
  height: 100vh;
}

.col {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  border-right: 3px solid var(--border);
}

.col:last-child {
  border-right: none;
}

.col-1 {
  background: #ffffff;
}

.col-2 {
  background: #f1f5f9;
}

.col-3 {
  background: #e2e8f0;
}

body.dark .col-1 {
  background: #1a1a1a;
}

body.dark .col-2 {
  background: #141414;
}

body.dark .col-3 {
  background: #0d0d0d;
}

.header-row {
  grid-column: 1 / -1;
  background: var(--bg);
  border-bottom: 3px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 72px;
  color: var(--fg);
  flex-shrink: 0;
}

.col-header {
  padding: 0 16px;
  border-bottom: 3px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
  background: var(--bg);
  color: var(--fg);
  height: 64px;
  flex-wrap: wrap;
}

.col-header h2 {
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--fg);
  margin: 0;
  flex-shrink: 0;
}

.formatting-toolbar {
  padding: 8px 16px;
  border-bottom: 3px solid var(--border);
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  background: var(--bg);
  flex-shrink: 0;
}

body.dark .formatting-toolbar {
  background: #1a1a1a;
}

.format-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--fg);
  cursor: pointer;
  transition: all 0.15s ease;
  font-weight: 800;
  font-size: 14px;
}

.format-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
  background: var(--border);
  color: var(--bg);
}

.format-btn:active {
  transform: translateY(0);
}

body.dark .format-btn {
  background: #1a1a1a;
}

body.dark .format-btn:hover {
  background: #525252;
  color: #f0f0f0;
}

.format-separator {
  width: 2px;
  height: 24px;
  background: var(--border);
  margin: 0 4px;
}

body.dark .format-separator {
  background: #525252;
}

.format-spacer {
  flex: 1;
}

.scrollbar-custom::-webkit-scrollbar {
  width: 12px;
}

.scrollbar-custom::-webkit-scrollbar-track {
  background: var(--bg);
  border-left: 3px solid var(--border);
}

.scrollbar-custom::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 6px;
}

.scrollbar-custom::-webkit-scrollbar-thumb:hover {
  background: #737373;
}

.article-text {
  font-size: 16px;
  line-height: 1.7;
  color: var(--fg);
  font-weight: 600;
  word-wrap: break-word;
}

.article-text p {
  margin-bottom: 1.15em;
}

.article-text h1 {
  font-size: 2rem;
  font-weight: 900;
  margin-bottom: 0.6rem;
}

.article-text h2 {
  font-size: 1.75rem;
  font-weight: 900;
  margin-bottom: 0.6rem;
}

.article-text h3 {
  font-size: 1.5rem;
  font-weight: 900;
  margin-bottom: 0.6rem;
}

.article-text strong {
  font-weight: 800;
}

.article-text em {
  font-style: italic;
}

.article-text del {
  text-decoration: line-through;
}

.article-text ul {
  list-style: disc;
  padding-left: 1.5em;
  margin-bottom: 1.15em;
}

.article-text ol {
  list-style: decimal;
  padding-left: 1.5em;
  margin-bottom: 1.15em;
}

.article-text li {
  margin-bottom: 0.3em;
}

.article-text blockquote {
  border-left: 4px solid var(--border);
  padding-left: 1em;
  margin: 1em 0;
  opacity: 0.8;
}

.article-text code {
  background: rgba(99, 102, 241, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
}

.article-text pre {
  background: rgba(99, 102, 241, 0.1);
  padding: 1em;
  border-radius: 4px;
  overflow-x: auto;
  margin: 1em 0;
}

.article-text pre code {
  background: none;
  padding: 0;
}

.article-text a {
  color: #6366f1;
  text-decoration: underline;
}

.article-text hr {
  border: 0;
  border-top: 3px solid var(--border);
  margin: 24px 0;
}

.edit-textarea {
  width: 100%;
  height: 100%;
  padding: 24px 32px;
  background: var(--bg);
  border: 3px dashed #6366f1;
  border-radius: var(--radius);
  font-family: 'Source Code Pro', monospace;
  font-size: 14px;
  line-height: 1.6;
  color: var(--fg);
  resize: none;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.edit-textarea:focus {
  outline: none;
  border-color: #818cf8;
}

body.dark .edit-textarea {
  background: #1a1a1a;
}

.selection-active {
  background: #F5B201 !important;
  border-color: var(--border) !important;
  color: #0f172a !important;
  border-radius: 4px;
}

body.dark .selection-active {
  background: #F5B201 !important;
  color: #0f172a !important;
}

.card-item {
  background: var(--bg);
  border: 3px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 14px 16px 12px;
  margin-bottom: 12px;
  cursor: grab;
  position: relative;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.card-item:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.card-item.dragging {
  opacity: 0.5;
  cursor: grabbing;
  border-style: dashed;
}

.card-item .card-index {
  position: absolute;
  left: -3px;
  top: -3px;
  background: var(--border);
  color: var(--bg);
  min-width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  border-radius: 0 0 8px 0;
}

body.dark .card-item .text-slate-900 {
  color: #f0f0f0 !important;
}

body.dark .card-item .text-slate-600 {
  color: #a3a3a3 !important;
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--fg);
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.icon-btn:hover {
  transform: translateY(-2px);
  box-shadow: 3px 3px 0px 0px var(--border);
  background: #6366f1;
  color: white;
}

body.dark .icon-btn:hover {
  background: #525252;
}

.icon-btn.delete:hover {
  background: #EA5252;
  color: white;
}

.icon-btn.copy:hover {
  background: #2B8E2B;
  color: white;
}

.empty-state-step {
  background: var(--bg);
  border: 3px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 16px 16px 16px 60px;
  margin-bottom: 12px;
  position: relative;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.empty-state-step:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.empty-state-step .step-num {
  position: absolute;
  left: 14px;
  top: 14px;
  width: 32px;
  height: 32px;
  background: var(--border);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  border-radius: 50%;
}

.empty-state-step h4 {
  font-size: 14px;
  font-weight: 800;
  margin-bottom: 4px;
  color: var(--fg);
}

.empty-state-step p {
  font-size: 13px;
  opacity: 0.8;
  line-height: 1.5;
  color: var(--fg);
  font-weight: 600;
}

body.dark .empty-state-step {
  background: #1a1a1a;
  border-color: #525252;
}

.toast {
  animation: toastIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

body.dark .toast {
  background: #262626;
  border-color: #525252;
  color: #f0f0f0;
}

.modal-backdrop {
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(4px);
}

.flip-card {
  perspective: 1000px;
  position: relative;
}

.flip-inner {
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
}

.flip-inner.flipped {
  transform: rotateY(180deg);
}

.flip-face {
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius);
}

.flip-back {
  transform: rotateY(180deg);
}

body.dark .flip-face {
  border-color: #525252 !important;
}

body.dark .flip-face.bg-green-100 {
  background: #1a2e1a !important;
}

body.dark .flip-face.bg-blue-100 {
  background: #1a2332 !important;
}

body.dark .flip-face .text-green-800 {
  color: #86efac !important;
}

body.dark .flip-face .text-blue-800 {
  color: #93c5fd !important;
}

@keyframes slideInFromRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideInFromLeft {
  from {
    transform: translateX(-100%);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.card-slide-in-right {
  animation: slideInFromRight 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.card-slide-in-left {
  animation: slideInFromLeft 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.loading-spinner {
  border: 4px solid var(--border);
  border-top: 4px solid #6366f1;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  100% {
    transform: rotate(360deg);
  }
}

.theme-toggle {
  width: 44px;
  height: 44px;
  border: 3px solid var(--border);
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--fg);
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.theme-toggle:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
}

.theme-toggle:active {
  transform: translateY(2px);
  box-shadow: var(--shadow-active);
}

body.dark .theme-toggle .icon-sun {
  display: none;
}

body:not(.dark) .theme-toggle .icon-moon {
  display: none;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg);
  transition: all 0.15s ease;
  text-decoration: none;
  padding: 8px 12px;
  border-radius: var(--radius);
}

.nav-link:hover {
  background: #F5B201;
  color: #0f172a;
}

.nav-link.active {
  background: #F5B201;
  color: #0f172a;
}

.nav-link i {
  font-size: 18px;
}

.empty-icon-container {
  width: 96px;
  height: 96px;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.9;
}

body.dark .empty-icon-container img {
  filter: invert(1);
}

.dropdown-menu {
  border: 3px solid var(--border);
  background: var(--bg);
  box-shadow: var(--shadow);
}

body.dark .dropdown-menu {
  background: #1a1a1a;
  border-color: #525252;
}

.dropdown-menu button {
  transition: all 0.15s ease;
}

.dropdown-menu button:hover {
  background: #F5B201 !important;
  color: #0f172a !important;
}

.dropdown-menu button:hover i {
  color: #0f172a !important;
}

.dropdown-divider {
  border-bottom: 2px solid var(--border);
}

body.dark .dropdown-divider {
  border-bottom-color: #525252;
}

.md-info-section {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 12px;
  background: var(--bg);
}

body.dark .md-info-section {
  background: #1a1a1a;
  border-color: #525252;
}

.md-info-section h4 {
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
  color: var(--fg);
  display: flex;
  align-items: center;
  gap: 6px;
}

.md-info-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
  font-size: 13px;
}

.md-info-row:not(:last-child) {
  border-bottom: 1px dashed var(--border);
}

body.dark .md-info-row:not(:last-child) {
  border-bottom-color: #404040;
}

.md-syntax {
  font-family: 'Source Code Pro', monospace;
  background: rgba(99, 102, 241, 0.1);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
  min-width: 100px;
  display: inline-block;
}

.md-result {
  flex: 1;
  color: var(--fg);
}

.study-hints {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--fg);
}

.study-hint-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.study-hint-divider {
  width: 2px;
  height: 20px;
  background: var(--border);
  opacity: 0.3;
}

.study-progress {
  text-align: center;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--fg);
  background: var(--bg);
  border: 3px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.study-progress-number {
  font-size: 20px;
  font-weight: 900;
  color: #136EB9;
}

@media (max-width: 1024px) {
  body {
    overflow: auto;
  }

  .app-grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto auto;
    height: auto;
  }

  .col {
    min-height: 480px;
    border-right: none;
    border-bottom: 3px solid var(--border);
  }

  .col-header {
    height: auto;
    min-height: 64px;
    padding: 16px;
  }
}
