:root {
  /* Light Theme Variables */
  --bg-color: #f4f6f9;
  --surface-color: rgba(255, 255, 255, 0.5);
  --text-primary: #2d3436;
  --text-secondary: #636e72;
  --accent-gradient: linear-gradient(135deg, #6c5ce7, #a29bfe);
  --accent-color: #6c5ce7;
  --border-color: rgba(0, 0, 0, 0.1);
  --shadow: 0 8px 32px rgba(108, 92, 231, 0.1);
  --success: #00b894;
  --danger: #d63031;
}

[data-theme="dark"] {
  /* Dark Theme Variables */
  --bg-color: #0f111a;
  --surface-color: rgba(30, 33, 43, 0.6);
  --text-primary: #f5f6fa;
  --text-secondary: #a4b0be;
  --accent-gradient: linear-gradient(135deg, #a29bfe, #81ecec);
  --accent-color: #a29bfe;
  --border-color: rgba(255, 255, 255, 0.1);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Outfit', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-primary);
  height: 100vh;
  margin: 0;
  display: flex;
  flex-direction: column;
  transition: background-color 0.4s ease, color 0.4s ease;
  overflow: hidden;
  justify-content: center;
  /* Center content vertically */
  align-items: center;
  /* Center content horizontally */
}

/* Background Flag Animations */
#flag-background {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: -1;
  opacity: 0;
  transition: opacity 1s ease-in-out, background 1s ease-in-out;
  pointer-events: none;
  background-size: cover;
  background-position: center;
  filter: blur(10px) saturate(150%);
}

#flag-background.show {
  opacity: 0.9;
  /* Increased visibility */
  animation: floatFlag 15s infinite alternate ease-in-out;
}

[data-theme="dark"] #flag-background.show {
  opacity: 1;
  /* Increased visibility for dark theme */
}

@keyframes floatFlag {
  0% {
    transform: scale(1) translate(0, 0);
  }

  50% {
    transform: scale(1.1) translate(20px, -20px);
  }

  100% {
    transform: scale(1.05) translate(-20px, 10px);
  }
}

/* Flag representations using CSS gradients to be lightweight */
/* USA/English */
#flag-background.flag-en {
  background-color: #ffffff !important;
  background-image: 
    linear-gradient(to bottom, #012169, #012169),
    repeating-linear-gradient(to bottom, #e0162b 0%, #e0162b 7.69%, #ffffff 7.69%, #ffffff 15.38%) !important;
  background-size: 50% 53.85%, 100% 100% !important;
  background-repeat: no-repeat, repeat !important;
  background-position: top left, center !important;
}

/* Spain */
.flag-es {
  background: linear-gradient(to bottom, #aa151b 0%, #aa151b 25%, #f1bf00 25%, #f1bf00 75%, #aa151b 75%, #aa151b 100%);
}

/* France */
.flag-fr {
  background: linear-gradient(to right, #002395 0%, #002395 33.33%, #ffffff 33.33%, #ffffff 66.67%, #ed2939 66.67%, #ed2939 100%);
}

/* Russia */
.flag-ru {
  background: linear-gradient(to bottom, #ffffff 0%, #ffffff 33.33%, #1c3578 33.33%, #1c3578 66.67%, #e4181c 66.67%, #e4181c 100%);
}

/* Netherlands */
.flag-nl {
  background: linear-gradient(to bottom, #ae1c28 0%, #ae1c28 33.33%, #ffffff 33.33%, #ffffff 66.67%, #21468b 66.67%, #21468b 100%);
}

/* Germany */
.flag-de {
  background: linear-gradient(to bottom, #000000 0%, #000000 33.33%, #dd0000 33.33%, #dd0000 66.67%, #ffce00 66.67%, #ffce00 100%);
}

/* India */
#flag-background.flag-hi,
#flag-background.flag-mr,
#flag-background.flag-te,
#flag-background.flag-ta,
#flag-background.flag-pa,
#flag-background.flag-gu,
#flag-background.flag-kn,
#flag-background.flag-ml {
  background-color: #ffffff !important;
  background-image: 
    radial-gradient(circle at center, transparent 15%, #000080 15%, #000080 18%, transparent 18%),
    linear-gradient(to bottom, #ff9933 0%, #ff9933 33.33%, transparent 33.33%, transparent 66.67%, #138808 66.67%, #138808 100%) !important;
}

/* China */
#flag-background.flag-zh {
  background-color: #ee1c25 !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23ffff00'%3E%3Cpath d='M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z'/%3E%3C/svg%3E") !important;
  background-size: 40% 40% !important;
  background-position: 10% 2% !important;
  background-repeat: no-repeat !important;
}

/* Denmark */
#flag-background.flag-da {
  background-color: #c60c30 !important;
  background-image: 
    linear-gradient(to bottom, transparent 42.85%, #ffffff 42.85%, #ffffff 57.14%, transparent 57.14%),
    linear-gradient(to right, transparent 28.57%, #ffffff 28.57%, #ffffff 39.28%, transparent 39.28%) !important;
  background-size: 100% 100% !important;
}

/* Norway */
#flag-background.flag-no {
  background-color: #ba0c2f !important;
  background-image: 
    linear-gradient(to bottom, transparent 37.5%, #00205b 37.5%, #00205b 62.5%, transparent 62.5%),
    linear-gradient(to right, transparent 27.27%, #00205b 27.27%, #00205b 45.45%, transparent 45.45%),
    linear-gradient(to bottom, transparent 31.25%, #ffffff 31.25%, #ffffff 68.75%, transparent 68.75%),
    linear-gradient(to right, transparent 22.72%, #ffffff 22.72%, #ffffff 50%, transparent 50%) !important;
  background-size: 100% 100% !important;
}

/* South Korea */
#flag-background.flag-ko {
  background-color: #ffffff !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 900 600'%3E%3Cpath fill='%23fff' d='M0 0h900v600H0z'/%3E%3Cg transform='translate(450,300)'%3E%3Cg stroke='%23000' stroke-width='15' stroke-linecap='square'%3E%3Cg transform='translate(-250,-166) rotate(33.69)'%3E%3Cpath d='M-50,-20h100M-50,0h100M-50,20h100'/%3E%3C/g%3E%3Cg transform='translate(250,166) rotate(33.69)'%3E%3Cpath d='M-50,-20h40m20,0h40M-50,0h40m20,0h40M-50,20h40m20,0h40'/%3E%3C/g%3E%3Cg transform='translate(250,-166) rotate(-33.69)'%3E%3Cpath d='M-50,-20h40m20,0h40M-50,0h100M-50,20h40m20,0h40'/%3E%3C/g%3E%3Cg transform='translate(-250,166) rotate(-33.69)'%3E%3Cpath d='M-50,-20h100M-50,0h40m20,0h40M-50,20h100'/%3E%3C/g%3E%3C/g%3E%3Ccircle r='150' fill='%230047a0'/%3E%3Cpath fill='%23cd2e3a' d='M-150,0A150,150 0 0,1 150,0A75,75 0 0,0 0,0A75,75 0 0,1 -150,0'/%3E%3C/g%3E%3C/svg%3E") !important;
  background-size: cover !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
}

/* Turkey */
#flag-background.flag-tr {
  background-color: #e30a17 !important;
  background-image: 
    radial-gradient(circle at 55% 50%, #e30a17 20%, transparent 20.5%),
    radial-gradient(circle at 45% 50%, #ffffff 25%, transparent 25.5%) !important;
  background-size: 100% 100% !important;
  background-position: center !important;
}

/* Vietnam */
#flag-background.flag-vi {
  background-color: #da251d !important;
  background-image: radial-gradient(circle at center, #ffff00 15%, transparent 15.5%) !important;
}

/* Saudi Arabia / Arabic */
#flag-background.flag-ar {
  background-color: #006c35 !important;
  background-image: linear-gradient(to right, transparent 20%, #ffffff 20%, #ffffff 80%, transparent 80%) !important;
  background-size: 100% 10% !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
}

/* Pakistan / Urdu */
#flag-background.flag-ur {
  background-color: #01411c !important;
  background-image: 
    linear-gradient(to right, #ffffff 0%, #ffffff 25%, transparent 25%),
    radial-gradient(circle at 65% 45%, #01411c 15%, transparent 15.5%),
    radial-gradient(circle at 55% 50%, #ffffff 20%, transparent 20.5%) !important;
  background-size: 100% 100% !important;
}

/* Bangladesh */
#flag-background.flag-bn {
  background-color: #006a4e !important;
  background-image: radial-gradient(circle at 45% 50%, #f42a41 20%, transparent 20.5%) !important;
}

/* Portugal */
#flag-background.flag-pt {
  background-color: #006600 !important;
  background-image: 
    radial-gradient(circle at 40% 50%, #ffff00 15%, transparent 15.5%),
    linear-gradient(to right, transparent 40%, #ff0000 40%, #ff0000 100%) !important;
}

/* Indonesia */
.flag-id {
  background: linear-gradient(to bottom, #ff0000 0%, #ff0000 50%, #ffffff 50%, #ffffff 100%);
}

/* Poland */
.flag-pl {
  background: linear-gradient(to bottom, #ffffff 0%, #ffffff 50%, #dc143c 50%, #dc143c 100%);
}

/* Japan */
#flag-background.flag-ja {
  background-color: #ffffff !important;
  background-image: radial-gradient(circle at center, #bc002d 32%, transparent 32.5%) !important;
}

/* Thailand */
.flag-th {
  background: linear-gradient(to bottom, #a51931 0%, #a51931 16.66%, #f4f5f8 16.66%, #f4f5f8 33.33%, #2d2a4a 33.33%, #2d2a4a 66.66%, #f4f5f8 66.66%, #f4f5f8 83.33%, #a51931 83.33%, #a51931 100%);
}

/* Italy */
.flag-it {
  background: linear-gradient(to right, #009246 0%, #009246 33.33%, #ffffff 33.33%, #ffffff 66.67%, #ce2b37 66.67%, #ce2b37 100%);
}

/* Malaysia */
#flag-background.flag-ms {
  background-color: #ffffff !important;
  background-image: 
    linear-gradient(to bottom, #010066, #010066),
    repeating-linear-gradient(to bottom, #e21118 0%, #e21118 7.1428%, #ffffff 7.1428%, #ffffff 14.2857%) !important;
  background-size: 50% 57.1428%, 100% 100% !important;
  background-repeat: no-repeat, repeat !important;
  background-position: top left, center !important;
}

/* Sweden */
#flag-background.flag-sv {
  background-color: #006aa7 !important;
  background-image: 
    linear-gradient(to bottom, transparent 40%, #fecc02 40%, #fecc02 60%, transparent 60%),
    linear-gradient(to right, transparent 31.25%, #fecc02 31.25%, #fecc02 43.75%, transparent 43.75%) !important;
  background-size: 100% 100% !important;
}

/* Ukraine */
#flag-background.flag-uk {
  background-color: #0057b7 !important;
  background-image: linear-gradient(to bottom, #0057b7 50%, #ffd700 50%) !important;
}

/* Finland */
#flag-background.flag-fi {
  background-color: #ffffff !important;
  background-image: 
    linear-gradient(to bottom, transparent 38%, #002f6c 38%, #002f6c 62%, transparent 62%),
    linear-gradient(to right, transparent 27%, #002f6c 27%, #002f6c 43%, transparent 43%) !important;
}

/* Greece */
#flag-background.flag-el {
  background-color: #001489 !important;
  background-image: 
    linear-gradient(to bottom, transparent 40%, #ffffff 40%, #ffffff 60%, transparent 60%),
    linear-gradient(to right, transparent 40%, #ffffff 40%, #ffffff 60%, transparent 60%),
    linear-gradient(to right, #001489 100%, transparent 100%),
    repeating-linear-gradient(to bottom, #001489 0%, #001489 11.11%, #ffffff 11.11%, #ffffff 22.22%) !important;
  background-size: 37% 55.55%, 37% 55.55%, 37% 55.55%, 100% 100% !important;
  background-position: top left, top left, top left, center !important;
  background-repeat: no-repeat, no-repeat, no-repeat, repeat !important;
}

/* Israel */
#flag-background.flag-he {
  background-color: #ffffff !important;
  background-image: 
    radial-gradient(circle at center, transparent 10%, #0038b8 10%, #0038b8 15%, transparent 15%),
    linear-gradient(to bottom, transparent 15%, #0038b8 15%, #0038b8 30%, transparent 30%, transparent 70%, #0038b8 70%, #0038b8 85%, transparent 85%) !important;
}

/* Czech Republic */
#flag-background.flag-cs {
  background-color: #ffffff !important;
  background-image: 
    linear-gradient(to bottom right, #11457e 50%, transparent 50%),
    linear-gradient(to top right, #11457e 50%, transparent 50%),
    linear-gradient(to bottom, transparent 50%, #d7141a 50%) !important;
  background-size: 50% 50.5%, 50% 50.5%, 100% 100% !important;
  background-position: top left, bottom left, center !important;
  background-repeat: no-repeat, no-repeat, repeat !important;
}

/* Romania */
.flag-ro {
  background: linear-gradient(to right, #002b7f 0%, #002b7f 33.33%, #fce116 33.33%, #fce116 66.67%, #ce1126 66.67%, #ce1126 100%);
}

/* App Container (Glassmorphism) */
.app-container {
  width: 100%;
  height: 100%;
  background: var(--surface-color);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 1.5rem 0.5rem 0.5rem 1rem;
  /* Reduced right padding for wider note space, and left padding for wider text area */
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 1;
}

/* Header */

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: 15px;
}

.logo h1 {
  font-size: 2rem;
  font-weight: 800;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  color: transparent;
  letter-spacing: -1px;
}

.emoji {
  font-size: 2rem;
  animation: bounce 2s infinite ease-in-out;
  display: inline-block;
}

@keyframes bounce {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-5px);
  }
}



[data-theme="dark"] .icon.sun {
  display: none;
}

[data-theme="light"] .icon.sun {
  display: inline-block;
}

[data-theme="dark"] .icon.moon {
  display: inline-block;
}

[data-theme="light"] .icon.moon {
  display: none;
}

body:not([data-theme]) .icon.sun {
  display: none;
}

/* Main Content */
.app-main {
  display: flex;
  flex-direction: row;
  gap: 0.25rem;
  flex-grow: 1;
  overflow: hidden;
}

.main-content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  flex-grow: 1;
  max-width: calc(100% - 90px);
  /* Fill remaining space minus adjusted wider sidebar */
  margin-right: -2rem;
  /* Pull slightly closer to the right edge */
  margin-top: 0.5rem;
  overflow: visible; /* Prevent absolute children from being clipped */
  position: relative; /* Set position relative for absolute children like find-panel */
}

.left-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  justify-content: flex-start;
  padding-top: 85px;
  width: 95px;
  flex-shrink: 0;
}

.btn-sidebar {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  min-height: 70px;
  height: auto;
  padding: 0.6rem 0.1rem;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  background: transparent;
  color: var(--text-primary);
}

.btn-sidebar:hover {
  background: var(--surface-color);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .btn-sidebar:hover {
  box-shadow: 0 4px 12px rgba(255, 255, 255, 0.05);
}

.btn-sidebar .icon {
  font-size: 1.9rem;
  flex-shrink: 0;
}

.share-icon-css {
  display: inline-block;
  width: 1.9rem;
  height: 1.9rem;
  background-color: var(--accent-color);
  background-image: var(--accent-gradient);
  -webkit-mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' width='24px' height='24px' stroke='currentColor' stroke-width='2' fill='none' class='icon' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='12' cy='12' r='11'%3E%3C/circle%3E%3Cline x1='7' y1='12' x2='16' y2='6.5'%3E%3C/line%3E%3Cline x1='7' y1='12' x2='16' y2='17.5'%3E%3C/line%3E%3Ccircle cx='16' cy='6.5' r='2.5' fill='currentColor'%3E%3C/circle%3E%3Ccircle cx='7' cy='12' r='2.5' fill='currentColor'%3E%3C/circle%3E%3Ccircle cx='16' cy='17.5' r='2.5' fill='currentColor'%3E%3C/circle%3E%3C/svg%3E") no-repeat center / contain;
  mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' width='24px' height='24px' stroke='currentColor' stroke-width='2' fill='none' class='icon' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='12' cy='12' r='11'%3E%3C/circle%3E%3Cline x1='7' y1='12' x2='16' y2='6.5'%3E%3C/line%3E%3Cline x1='7' y1='12' x2='16' y2='17.5'%3E%3C/line%3E%3Ccircle cx='16' cy='6.5' r='2.5' fill='currentColor'%3E%3C/circle%3E%3Ccircle cx='7' cy='12' r='2.5' fill='currentColor'%3E%3C/circle%3E%3Ccircle cx='16' cy='17.5' r='2.5' fill='currentColor'%3E%3C/circle%3E%3C/svg%3E") no-repeat center / contain;
}

.sidebar-text {
  font-size: 0.70rem;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  letter-spacing: -0.2px;
  line-height: 1.3;
  padding-bottom: 2px;
}

/* Header Controls (Theme Toggle) */
#theme-toggle {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 50%;
  transition: transform 0.3s ease, background 0.3s ease;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

#theme-toggle:hover {
  background: var(--border-color);
  transform: rotate(15deg) scale(1.1);
}

/* Modal System */
.lang-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.lang-modal.hidden {
  opacity: 0;
  pointer-events: none;
}

.lang-modal-content {
  background: var(--surface-color);
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  border-radius: 24px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  transform: scale(1);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  overflow: hidden;
}

[data-theme="dark"] .lang-modal-content {
  background: rgba(30, 33, 43, 0.85);
}

.lang-modal.hidden .lang-modal-content {
  transform: scale(0.95) translateY(20px);
}

.lang-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--border-color);
  position: relative;
}

.lang-modal-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
  flex-grow: 1;
  text-align: left;
  margin: 0;
  white-space: pre-wrap;
}

.icon-button {
  background: transparent;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 50%;
  transition: background 0.2s ease, transform 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
}

.icon-button:hover {
  background: var(--border-color);
  transform: scale(1.1);
}

.icon-button.hidden {
  opacity: 0;
  pointer-events: none;
}

.lang-modal-body {
  padding: 1.5rem 2rem;
  overflow-y: auto;
  flex-grow: 1;
  position: relative;
}

/* Custom Scrollbar for Modal Body */
.lang-modal-body::-webkit-scrollbar {
  width: 8px;
}

.lang-modal-body::-webkit-scrollbar-track {
  background: transparent;
}

.lang-modal-body::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 10px;
}

.lang-modal-body::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* Country Grid */
.lang-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1rem;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.lang-grid.hidden {
  display: none;
}

.country-card {
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.country-card:hover {
  background: var(--border-color);
  transform: translateY(-4px);
  border-color: var(--accent-color);
  box-shadow: 0 4px 12px rgba(108, 92, 231, 0.15);
}

.country-card.selected {
  background: rgba(108, 92, 231, 0.1);
  border-color: var(--accent-color);
  box-shadow: 0 4px 12px rgba(108, 92, 231, 0.2);
  transform: translateY(-2px);
}

[data-theme="dark"] .country-card.selected {
  background: rgba(162, 155, 254, 0.15);
}

.country-card .flag-icon {
  font-size: 2.5rem;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.country-card .country-text-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
}

.country-card .country-name {
  font-size: 0.95rem;
  font-weight: 600;
  text-align: center;
  color: var(--text-primary);
  line-height: 1.1;
}

.country-card .country-native-name {
  font-size: 0.8rem;
  font-weight: 400;
  text-align: center;
  color: var(--text-secondary);
}

/* State/Language List */
.lang-list {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.lang-list.hidden {
  display: none;
}

.state-item {
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-primary);
}

.state-item:hover {
  background: var(--border-color);
  border-color: var(--accent-color);
  transform: translateX(4px);
}

.state-item.selected {
  background: var(--accent-gradient);
  color: white;
  border-color: transparent;
  font-weight: 600;
}

.state-item .state-label {
  flex-grow: 1;
}

.state-item .check-icon {
  opacity: 0;
  transform: scale(0.5);
  transition: all 0.2s ease;
}

.state-item.selected .check-icon {
  opacity: 1;
  transform: scale(1);
}

/* ============================================================
   Find & Replace – Sidebar Icon
   ============================================================ */
.find-icon-css {
  display: inline-block;
  width: 1.9rem;
  height: 1.9rem;
  background-color: var(--accent-color);
  background-image: var(--accent-gradient);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E") no-repeat center / contain;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E") no-repeat center / contain;
}

/* Active state for sidebar find button */
#btn-find-replace.active {
  background: rgba(108, 92, 231, 0.12);
  border-radius: 12px;
}

/* ============================================================
   Find & Replace – Floating Panel
   ============================================================ */
.find-panel {
  position: absolute;
  top: 4px;
  right: 20px;
  z-index: 200;
  width: 360px;
  background: var(--surface-color);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1.5px solid var(--border-color);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(108, 92, 231, 0.15), 0 2px 8px rgba(0,0,0,0.08);
  animation: frSlideDown 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  overflow: hidden;
}

.find-panel.find-panel--wide {
  width: 420px;
}

.rtl-mode .find-panel {
  right: auto;
  left: 20px;
}

[data-theme="dark"] .find-panel {
  background: rgba(20, 23, 35, 0.88);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 2px 8px rgba(162, 155, 254, 0.12);
}

.find-panel.hidden {
  display: none;
}

@keyframes frSlideDown {
  from { opacity: 0; transform: translateY(-12px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)   scale(1);    }
}

/* Panel Header */
.find-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 1rem 0.5rem 1rem;
  border-bottom: 1px solid var(--border-color);
}

.find-panel-title {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  color: transparent;
}

.find-close-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0.25rem 0.4rem;
  border-radius: 8px;
  line-height: 1;
  transition: background 0.2s ease, color 0.2s ease;
}

.find-close-btn:hover {
  background: rgba(214, 48, 49, 0.1);
  color: #d63031;
}

/* Panel Body */
.find-panel-body {
  padding: 0.8rem 1rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.find-panel-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.find-input-wrap {
  flex: 1;
  position: relative;
}

.find-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
  background: var(--bg-color);
  border: 1.5px solid var(--border-color);
  border-radius: 10px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  caret-color: var(--accent-color);
}

.find-input::placeholder {
  color: var(--text-secondary);
  opacity: 0.6;
}

.find-input:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.12);
}

/* Match Status */
.match-status {
  font-size: 0.82rem;
  font-weight: 700;
  min-height: 1.1em;
  padding: 0 0.1rem;
  transition: color 0.2s ease;
}

.match-status.match-found {
  color: #00b894;
}

.match-status.match-none {
  color: #d63031;
}

/* Action Buttons */
.find-panel-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.2rem;
  flex-wrap: wrap;
}

.find-action-btn {
  flex: 1;
  min-width: 80px;
  padding: 0.45rem 0.6rem;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  border: none;
  border-radius: 9px;
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--border-color);
  color: var(--text-primary);
  white-space: normal;
  word-break: break-word;
  line-height: 1.2;
}

.find-action-btn:hover {
  background: rgba(108, 92, 231, 0.15);
  color: var(--accent-color);
  transform: translateY(-1px);
}

.find-action-btn:active {
  transform: translateY(0) scale(0.97);
}

.find-action-btn--replace {
  background: rgba(9, 132, 227, 0.12);
  color: #0984e3;
}

.find-action-btn--replace:hover {
  background: rgba(9, 132, 227, 0.22);
  color: #0984e3;
}

.find-action-btn--replace-all {
  background: rgba(108, 92, 231, 0.12);
  color: var(--accent-color);
}

.find-action-btn--replace-all:hover {
  background: rgba(108, 92, 231, 0.25);
  color: var(--accent-color);
}

/* ============================================================
   Find & Replace – Mirror Div (Highlight Layer)
   ============================================================ */
.fr-mirror {
  position: absolute;
  top: 0;
  bottom: 0;
  /* Sync with textarea via JS - font, size, leading, padding, offsets, direction */
  pointer-events: none;
  overflow: hidden;
  white-space: pre-wrap;
  word-wrap: break-word;
  color: transparent;
  background: transparent;
  z-index: 0;
  border: none;
  text-align: inherit;
}

/* Textarea sits on top of mirror — transparent BG when panel open */
textarea#notepad.fr-active-state {
  background: transparent !important;
  position: relative;
  z-index: 1;
}

/* Normal match highlight */
.fr-mirror mark.fr-match {
  background: rgba(253, 203, 110, 0.55);
  color: transparent;
  border-radius: 2px;
}

/* Active match highlight */
.fr-mirror mark.fr-active {
  background: rgba(9, 132, 227, 0.55);
  color: transparent;
  border-radius: 2px;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Tabs System */
.tabs-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: -2px;
  /* overlap border slightly */
  margin-left: 145px;
  z-index: 2;
  position: relative;
  top: 16px;
}

.tabs-list {
  display: flex;
  overflow-x: auto;
  gap: 0.25rem;
  scrollbar-width: none;
}

.tabs-list::-webkit-scrollbar {
  display: none;
}

.tab {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.8rem;
  background: var(--surface-color);
  border: 2px solid var(--border-color);
  border-bottom: none;
  border-radius: 10px 10px 0 0;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.2s ease;
  white-space: nowrap;
  max-width: 130px;
}

.tab.active {
  background: var(--bg-color);
  color: var(--text-primary);
  border-color: var(--border-color);
  /* match editor border */
  border-bottom: 2px solid var(--bg-color);
  /* hide bottom border to blend with editor */
  font-weight: 600;
  padding-bottom: 0.45rem;
  /* slightly taller to overlap */
}

.editor-container:focus-within {
  /* ensure focus ring doesn't mess up tab overlap */
  border-color: var(--accent-color);
}

.tab:hover:not(.active) {
  background: var(--border-color);
}

.tab-title {
  overflow: hidden;
  text-overflow: ellipsis;
}

.tab-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  font-size: 0.65rem;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-close:hover {
  background: rgba(214, 48, 49, 0.1);
  color: #d63031;
}

.btn-add-tab {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: transparent;
  border: 1px dashed var(--border-color);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.btn-add-tab svg {
  width: 14px;
  height: 14px;
}

.btn-add-tab:hover {
  background: var(--border-color);
  border-style: solid;
  color: var(--text-primary);
}

.editor-container {
  position: relative;
  width: 100%;
  flex-grow: 1;
  display: flex;
  background: var(--bg-color);
  border: 2px solid var(--border-color);
  border-radius: 0 16px 16px 16px;
  /* Flat top-left for tabs */
  overflow: hidden;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.line-numbers {
  display: flex;
  flex-direction: column;
  padding: 1.5rem 0.5rem 1.5rem 1.5rem;
  text-align: right;
  font-family: inherit;
  font-size: 1.1rem;
  line-height: 1.6;
  color: var(--text-secondary);
  user-select: none;
  opacity: 0.6;
  overflow: hidden;
  min-width: 3rem;
}

.line-numbers div {
  transition: color 0.2s ease, font-weight 0.2s ease;
}

.line-numbers div.active {
  color: #0984e3;
  /* Blue highlight */
  font-weight: 800;
  opacity: 1;
  /* Make it pop out over the 0.6 container opacity */
}

.rtl-mode .editor-container {
  flex-direction: row-reverse;
}

.rtl-mode .editor-container .line-numbers {
  text-align: left;
  padding: 1.5rem 1.5rem 1.5rem 0.5rem;
}

.editor-container:focus-within {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 4px rgba(108, 92, 231, 0.1);
}

/* Force Notepad Selection to stay solid blue even when blurred/unfocused */
textarea#notepad::selection {
  background-color: #0984e3 !important;
  color: #ffffff !important;
}

textarea#notepad::-moz-selection {
  background-color: #0984e3 !important;
  color: #ffffff !important;
}


/* Fake blinking text cursor for Find/Replace inputs when notepad has focus */
@keyframes fake-caret-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

.fake-caret {
  display: none;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 1.5px;
  height: 1.1em;
  background-color: var(--text-primary, #333);
  animation: fake-caret-blink 1s step-end infinite;
  pointer-events: none;
  z-index: 10;
}

.fake-caret.visible {
  display: block;
}

/* Keep the input caret visible by default; hide it only when virtual-focused */
input.virtual-focused {
  caret-color: transparent;
}


textarea#notepad {
  width: 100%;
  height: 100% !important;
  background: var(--bg-color);
  border: none;
  border-radius: 0;
  padding: 1.5rem;
  padding-left: 1rem;
  font-family: inherit;
  font-size: 1.1rem;
  line-height: 1.6;
  color: var(--text-primary);
  resize: none;
  outline: none;
  z-index: 1;
  position: relative;
  opacity: 1;
  /* Ensure notepad is fully opaque */
}

textarea#notepad::placeholder {
  color: var(--text-secondary);
  opacity: 0.7;
}

/* Custom Scrollbar for Notepad Area */
textarea#notepad::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

textarea#notepad::-webkit-scrollbar-track {
  background: transparent;
}

textarea#notepad::-webkit-scrollbar-thumb {
  background: var(--text-secondary);
  border-radius: 10px;
  border: 2px solid var(--bg-color);
}

textarea#notepad::-webkit-scrollbar-thumb:hover {
  background: var(--accent-color);
}


/* Status Bar & Buttons */
.status-bar {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: auto;
  width: 100%;
  padding-left: 94px;
  transform: translateY(0);
}

.stats {
  font-size: 0.95rem;
  color: var(--text-secondary);
  font-weight: 600;
  background: var(--bg-color);
  padding: 0.5rem 1rem;
  border-radius: 20px;
  border: 1px solid var(--border-color);
}

.btn {
  font-family: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.7rem 1.2rem;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  position: relative;
  overflow: hidden;
  z-index: 1;
}

.btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.1);
  z-index: -1;
  transform: scaleY(0);
  transform-origin: bottom;
  transition: transform 0.3s ease;
}

.btn:hover::before {
  transform: scaleY(1);
}

.btn:active {
  transform: scale(0.95);
}

.btn-funky {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: 30px;
  box-shadow: 3px 3px 0px rgba(0, 0, 0, 0.15);
  border: 2px solid transparent;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

[data-theme="dark"] .btn-funky {
  box-shadow: 3px 3px 0px rgba(255, 255, 255, 0.15);
}

.btn-funky:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 5px 5px 0px rgba(0, 0, 0, 0.15);
}

[data-theme="dark"] .btn-funky:hover {
  box-shadow: 5px 5px 0px rgba(255, 255, 255, 0.15);
}

.btn-funky:active {
  transform: translateY(1px) scale(0.98);
  box-shadow: 1px 1px 0px rgba(0, 0, 0, 0.15);
}

[data-theme="dark"] .btn-funky:active {
  box-shadow: 1px 1px 0px rgba(255, 255, 255, 0.15);
}

.btn-funky .icon {
  font-size: 1.1rem;
}

/* Specific Buttons */
.btn-funky.btn-copy {
  background: var(--accent-gradient);
  color: white;
  border-color: var(--accent-color);
}

.btn-funky.btn-download {
  background: linear-gradient(135deg, #0984e3, #74b9ff);
  color: white;
  border-color: #0984e3;
}

.btn-funky.btn-clear {
  background: linear-gradient(135deg, #d63031, #ff7675);
  color: white;
  border-color: #d63031;
}

.btn-funky.success {
  background: linear-gradient(135deg, #00b894, #55efc4) !important;
  border-color: #00b894 !important;
}

.app-footer {
  display: none;
}

/* Stylish Theme Options */
.theme-options {
  display: flex;
  gap: 1rem;
  width: 100%;
}

.theme-option {
  flex: 1;
  cursor: pointer;
  position: relative;
}

.theme-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.theme-card {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.4rem 0.6rem;
  background: transparent;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  color: var(--text-secondary);
}

.theme-card .icon {
  font-size: 1rem;
  transition: transform 0.3s ease;
}

.theme-card .label {
  font-size: 0.75rem;
  font-weight: 600;
}

.theme-option:hover .theme-card {
  border-color: var(--text-secondary);
  background: rgba(0, 0, 0, 0.02);
}

[data-theme="dark"] .theme-option:hover .theme-card {
  background: rgba(255, 255, 255, 0.05);
}

.theme-option input[type="radio"]:checked+.theme-card {
  border-color: var(--accent-color);
  background: var(--surface-color);
  color: var(--text-primary);
  box-shadow: 0 4px 12px rgba(108, 92, 231, 0.15);
  /* matching accent glow */
}

.theme-option input[type="radio"]:checked+.theme-card .icon {
  transform: scale(1.15);
}

/* Info Icon & Custom Tooltip Styling */
.info-icon-container {
  position: relative;
  display: inline-flex;
  margin-left: 0.2rem;
}

.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #0984e3;
  /* Blue color */
  cursor: help;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.info-icon:hover {
  opacity: 0.8;
  transform: scale(1.1);
}

.custom-tooltip {
  position: absolute;
  bottom: 150%;
  top: auto;
  left: 50%;
  background: #000000;
  color: #0984e3;
  border: 1px solid #0984e3;
  padding: 0.6rem;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.4;
  white-space: normal;
  width: max-content;
  max-width: 210px;
  opacity: 0;
  pointer-events: none;
  transform: translateX(-20%) translateY(10px);
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  z-index: 100;
  text-align: left;
}

.info-icon-container:hover .custom-tooltip {
  opacity: 1;
  transform: translateX(-20%) translateY(0);
}

/* Custom Settings Checkbox */
.blue-tick-checkbox {
  appearance: none;
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  background-color: var(--surface-color);
  border: 2px solid var(--border-color);
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
  margin: 0;
  display: inline-block;
  vertical-align: middle;
}

.blue-tick-checkbox:checked {
  background-color: #0984e3;
  border-color: #0984e3;
}

.blue-tick-checkbox:checked::after {
  content: '';
  position: absolute;
  left: 7px;
  top: 3px;
  width: 5px;
  height: 10px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* Responsive */
@media (max-width: 768px) {
  .app-container {
    padding: 0.5rem;
    width: 100%;
    height: 100%;
    /* Full height on small screens */
    border-radius: 0;
  }

  .app-header {
    flex-direction: column;
    gap: 0.5rem;
  }

  .app-main {
    flex-direction: column-reverse;
  }

  .left-sidebar {
    flex-direction: row;
    width: 100%;
    padding-top: 0;
    height: auto;
    justify-content: space-around;
    gap: 0.2rem;
  }

  .main-content {
    max-width: 100%;
    margin-right: 0;
    margin-top: 0;
  }

  .btn-sidebar {
    min-height: auto;
    padding: 0.4rem;
  }

  .btn-sidebar .icon {
    font-size: 1.5rem;
  }

  .sidebar-text {
    display: none;
  }

  .status-bar {
    flex-direction: column;
    align-items: center;
    padding-left: 0;
  }

  .action-buttons {
    width: 100%;
    margin-top: 0.5rem;
    margin-right: 0;
    margin-bottom: 0.5rem;
  }

  .btn {
    flex: 1;
  }
}

/* Reset Preferences Option */
.reset-preferences {
  color: var(--text-primary);
  font-weight: 600;
  cursor: pointer;
  transition: color 0.2s ease;
  text-decoration: none;
}

.reset-preferences:hover {
  color: #0984e3;
  text-decoration: underline;
}

/* Specific tooltip position for Reset Preferences to appear on top */
.reset-preferences-tooltip {
  top: auto;
  bottom: 150%;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
}

.info-icon-container:hover .reset-preferences-tooltip {
  transform: translateX(-50%) translateY(0);
}

/* ============================================================
   Funky About Icon
   ============================================================ */
.about-icon-funky {
  display: inline-block;
  width: 1.9rem;
  height: 1.9rem;
  background-color: var(--accent-color);
  background-image: linear-gradient(45deg, #ff00cc, #3333ff, #00ffcc, #ff00cc);
  background-size: 300% 300%;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'%3E%3C/circle%3E%3Cline x1='12' y1='16' x2='12' y2='12'%3E%3C/line%3E%3Cline x1='12' y1='8' x2='12.01' y2='8'%3E%3C/line%3E%3C/svg%3E") no-repeat center / contain;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'%3E%3C/circle%3E%3Cline x1='12' y1='16' x2='12' y2='12'%3E%3C/line%3E%3Cline x1='12' y1='8' x2='12.01' y2='8'%3E%3C/line%3E%3C/svg%3E") no-repeat center / contain;
  animation: funkyIconGradient 3s ease infinite, funkyIconBounce 2s infinite alternate;
}

@keyframes funkyIconGradient {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes funkyIconBounce {
  0% { transform: scale(1) rotate(0deg); }
  50% { transform: scale(1.15) rotate(10deg); }
  100% { transform: scale(1.05) rotate(-10deg); }
}