/* ===== CSS Variables ===== */
:root {
  /* Light theme colors */
  --bg-primary: #f5f5f5;
  --text-primary: #333333;
  --text-secondary: #666666;
  --border-color: #e0e0e0;
  --accent: #7c5cff;
  --selection-bg: rgba(50, 120, 200, 0.18);
  --icon-hover-bg: rgba(0, 0, 0, 0.08);
  --popup-bg: #ffffff;
  --popup-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  --shortcuts-bg: #2a2a2a;
  --toggle-off-bg: #cccccc;
}

/* Dark theme colors */
[data-theme="dark"] {
  --bg-primary: #1a1a1a;
  --text-primary: #f5f5f5;
  --text-secondary: #cccccc;
  --border-color: #444444;
  --selection-bg: rgba(124, 92, 255, 0.25);
  --icon-hover-bg: rgba(255, 255, 255, 0.08);
  --popup-bg: #2a2a2a;
  --popup-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shortcuts-bg: #333333;
  --toggle-off-bg: #555555;
}

/* ===== Base Styles ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: var(--bg-primary);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  height: 100vh;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.3s ease;
}

/* ===== Icon Buttons ===== */
.icon-btn {
  position: fixed;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.2s ease;
  z-index: 100;
}

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

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

.icon-btn svg path {
  stroke: var(--text-primary);
  fill: none;
  transition: stroke 0.2s ease;
}

.icon-btn svg path[fill]:not([fill="none"]) {
  fill: var(--text-primary);
  stroke: none;
  transition: fill 0.2s ease;
}

.theme-toggle {
  top: 20px;
  left: 20px;
}

.help-btn {
  top: 20px;
  right: 20px;
}

/* ===== Viewport / Text Area ===== */
.viewport {
  position: relative;
  width: 260px;
  height: 40px;
  overflow: hidden;
  background: transparent;
  border-radius: 6px;
}

.text-area {
  position: absolute;
  top: 0;
  left: 12px;
  white-space: pre;
  font-size: 1rem;
  line-height: 1.6rem;
  font-family: inherit;
  color: var(--text-primary);
  z-index: 5;
  pointer-events: none;
  transform: translate(0px, 0px);
  transition: transform 160ms cubic-bezier(0.2, 0.9, 0.2, 1), color 0.3s ease;
  will-change: transform;
}

.text-area .sel {
  background: var(--selection-bg);
}

.text-area .cursor {
  display: inline-block;
  width: 2px;
  height: 1.6rem;
  background: var(--text-primary);
  animation: blink 1s infinite;
  vertical-align: top;
  transition: background-color 0.3s ease;
}

@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

/* ===== Masks for fade effect ===== */
.mask {
  position: absolute;
  z-index: 10;
  pointer-events: none;
  transition: background 0.3s ease;
}

.mask.left {
  left: 0;
  top: 0;
  width: 24px;
  height: 100%;
  background: linear-gradient(to right, var(--bg-primary), transparent);
}

.mask.right {
  right: 0;
  top: 0;
  width: 32px;
  height: 100%;
  background: linear-gradient(to left, var(--bg-primary), transparent);
}

.mask.top {
  left: 0;
  top: 0;
  width: 100%;
  height: 14px;
  background: linear-gradient(to bottom, var(--bg-primary), transparent);
}

.mask.bottom {
  left: 0;
  right: 0;
  bottom: 0;
  height: 14px;
  background: linear-gradient(to top, var(--bg-primary), transparent);
}

/* ===== Invisible Textarea ===== */
.invisible-textarea {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  resize: none;
  overflow: hidden;
  background: transparent;
  border: none;
  outline: none;
  color: transparent;
  caret-color: transparent;
  font-size: 1rem;
  line-height: 1.6rem;
  font-family: inherit;
  z-index: 20;
  padding-left: 12px;
  padding-right: 12px;
  white-space: pre;
}

.invisible-textarea::selection {
  background: transparent;
  color: transparent;
}

.invisible-textarea::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.invisible-textarea {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

/* ===== Sizer (for measuring text) ===== */
.sizer {
  position: fixed;
  left: -9999px;
  top: -9999px;
  white-space: pre;
  font-size: 1rem;
  line-height: 1.6rem;
  font-family: inherit;
  visibility: hidden;
}

/* ===== Popup Overlay ===== */
.popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.popup-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* ===== Popup Container ===== */
.popup {
  background: var(--popup-bg);
  border-radius: 16px;
  padding: 24px;
  min-width: 380px;
  max-width: 420px;
  box-shadow: var(--popup-shadow);
  transform: scale(0.9);
  transition: transform 0.3s ease, background-color 0.3s ease;
}

.popup-overlay.active .popup {
  transform: scale(1);
}

/* ===== Popup Header ===== */
.popup-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
}

.popup-contact {
  display: flex;
  flex-direction: column;
}

.popup-contact-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
  transition: color 0.3s ease;
}

.popup-contact-email {
  font-size: 14px;
  color: var(--text-secondary);
  transition: color 0.3s ease;
}

.popup-social {
  display: flex;
  align-items: center;
  gap: 8px;
}

.popup-social .social-link {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background-color 0.2s ease;
  text-decoration: none;
}

.popup-social .social-link:hover {
  background-color: var(--icon-hover-bg);
}

.popup-social .social-link svg {
  width: 20px;
  height: 20px;
}

.popup-social .social-link svg path {
  fill: var(--text-primary);
  transition: fill 0.2s ease;
}

.popup-social .social-link svg path[stroke] {
  stroke: var(--text-primary);
  transition: stroke 0.2s ease;
}

.popup-social .separator {
  width: 1px;
  height: 20px;
  background: var(--border-color);
  margin: 0 4px;
  transition: background-color 0.3s ease;
}

/* ===== Theme Toggle Row ===== */
.theme-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.theme-row svg {
  width: 20px;
  height: 20px;
}

.theme-row svg path {
  fill: var(--text-primary);
  transition: fill 0.2s ease;
}

.theme-row-label {
  flex: 1;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
  transition: color 0.3s ease;
}

/* ===== Toggle Switch ===== */
.toggle-switch {
  position: relative;
  width: 48px;
  height: 26px;
  background: var(--toggle-off-bg);
  border-radius: 13px;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.toggle-switch.active {
  background: var(--accent);
}

.toggle-switch .toggle-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: #ffffff;
  border-radius: 50%;
  transition: transform 0.3s ease;
}

.toggle-switch.active .toggle-knob {
  transform: translateX(22px);
}

/* ===== Shortcuts Section ===== */
.shortcuts-section {
  background: var(--shortcuts-bg);
  border-radius: 12px;
  overflow: hidden;
}

.shortcuts-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.shortcuts-header svg {
  width: 20px;
  height: 20px;
}

.shortcuts-header svg path {
  fill: #ffffff;
}

.shortcuts-header-title {
  font-size: 14px;
  font-weight: 500;
  color: #ffffff;
}

.shortcuts-list {
  padding: 0;
}

.shortcut-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.shortcut-row:last-child {
  border-bottom: none;
}

.shortcut-name {
  font-size: 14px;
  color: #ffffff;
}

.shortcut-keys {
  display: flex;
  align-items: center;
  gap: 6px;
}

.shortcut-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 8px;
  background: var(--accent);
  color: #ffffff;
  font-size: 12px;
  font-weight: 500;
  border-radius: 6px;
}
