body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial;
    margin: 0;
    min-height: 100vh;
    background: #ffffff;
    color: #1d1d1f;
    position: relative; /* Needed for pseudo-element positioning */
    overflow-x: hidden; /* Prevent horizontal scroll from pseudo-elements */
    font-size: 16px;
    line-height: 1.6;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 20% 30%, rgba(0,0,0,0.02), transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(0,0,0,0.01), transparent 45%);
  pointer-events: none;
  z-index: -2;
}

.container {
    max-width: 768px;
    margin: 0 auto;
    padding: 24px;
    position: relative;
    z-index: 1;
    min-height: calc(100vh - 48px);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

@media (max-width: 768px) {
    .container {
        padding: 16px;
    }
}

.container::before {
    content: '';
    position: absolute;
    top: 10%;
    left: 5%;
    width: 100px;
    height: 100px;
    background: radial-gradient(circle, rgba(0, 0, 0, 0.02) 10%, transparent 40%);
    z-index: -1;
    animation: pulse 10s infinite;
}

.container::after {
    content: '';
    position: absolute;
    bottom: 15%;
    right: 10%;
    width: 150px;
    height: 150px;
    background: linear-gradient(45deg, rgba(0, 0, 0, 0.01), rgba(0, 0, 0, 0.02));
    clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
    z-index: -1;
    opacity: 0.5;
    animation: spin-slow 20s infinite linear;
}
.bg-animations {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -2;
    pointer-events: none;
}

.particles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
}

.particle {
    position: absolute;
    width: 8px;
    height: 8px;
    background: rgba(59, 130, 246, 0.4);
    border-radius: 50%;
    animation: float 15s infinite linear;
}

.particle:nth-child(2n) {
    background: rgba(96, 165, 250, 0.4);
}

.particle:nth-child(3n) {
    background: rgba(147, 197, 253, 0.4);
}

.particle:nth-child(4n) {
    background: rgba(191, 219, 254, 0.4);
}

.particle:nth-child(5n) {
    background: rgba(219, 234, 254, 0.4);
}

@keyframes float {
    0% {
        transform: translateY(100vh) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 0.5;
    }
    90% {
        opacity: 0.5;
    }
    100% {
        transform: translateY(-10vh) rotate(360deg);
        opacity: 0;
    }
}

.squiggly-line {
    stroke-dasharray: 1200;
    stroke-dashoffset: 1200;
    animation: draw 8s ease-in-out infinite;
}

.delay1 {
    animation-delay: 2s;
}

.delay2 {
    animation-delay: 4s;
}

@keyframes draw {
    0% { stroke-dashoffset: 1200; }
    50% { stroke-dashoffset: 0; }
    100% { stroke-dashoffset: -1200; }
}
@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 0.1; }
    50% { transform: scale(1.2); opacity: 0.2; }
}

@keyframes spin-slow {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.card-wrap {
  position: relative;
  width: 100%; /* Ensure it takes full width of its grid cell */
}

.card-wrap::before {
  content: "";
  position: absolute;
  inset: -14px;
  border-radius: 28px;
  background: rgba(255,255,255,0.25);
  filter: blur(18px);
  z-index: -1;
}

.title {
    text-align: center;
    font-size: 3.5rem;
    font-weight: 900;
    margin-bottom: 16px;
    color: #1d1d1f;
    text-shadow: 3px 3px 0px rgba(0,0,0,0.1);
    letter-spacing: -0.02em;
    line-height: 1.1;
    font-family: 'Courier New', monospace; /* Retro font */
}

@media (max-width: 768px) {
    .title {
        font-size: 2.5rem;
    }
}

.slogan {
    text-align: center;
    font-size: 1.25rem;
    font-weight: 400;
    margin-bottom: 40px;
    opacity: 0.8;
    color: #6b7280;
    letter-spacing: 0.01em;
}

@media (max-width: 768px) {
    .slogan {
        font-size: 1rem;
        margin-bottom: 32px;
    }
}

.instructions {
    text-align: left;
    margin-top: 40px;
    margin-bottom: 40px;
    font-size: 1rem;
    opacity: 0.9;
    background: rgba(255, 255, 255, 0.8);
    padding: 24px;
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

@media (max-width: 768px) {
    .instructions {
        margin-top: 24px;
        margin-bottom: 24px;
        padding: 20px;
    }
}

.instructions h3 {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 16px;
    color: #1d1d1f;
    letter-spacing: -0.02em;
}

.instructions p {
    margin-bottom: 12px;
    line-height: 1.6;
    font-size: 1rem;
    color: #374151;
}

.instructions strong {
    color: #111827;
    font-weight: 600;
}

.footer-note {
    margin-top: 48px;
    text-align: center;
    font-size: 0.85rem;
    color: rgba(0,0,0,0.55);
    line-height: 1.4;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  margin-top: 32px;
  position: relative; /* For doodle positioning */
}

@media (max-width: 768px) {
    .grid {
        grid-template-columns: 1fr;
        gap: 24px;
    }
}

.doodle {
  position: absolute;
  font-size: 24px;
  opacity: 0.15;
  color: #18181b; /* Inherit text color for subtle appearance */
  pointer-events: none; /* Allow clicks to pass through */
}

.doodle.arrow {
  top: 55%;
  left: 48%;
  transform: rotate(12deg);
  content: "→"; /* Unicode arrow character */
}

@media (max-width: 768px) {
    .doodle.arrow {
        display: none; /* Hide on mobile since it's single column */
    }
}

.editor,
.textarea-container textarea {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 20px;
  padding: 20px;
  min-height: 240px;
  border: none;
  box-shadow:
    0 10px 30px rgba(0, 0, 0, 0.08),
    inset 0 0 0 2px rgba(0, 0, 0, 0.03);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.editor:focus,
.textarea-container textarea:focus {
    outline: none;
    box-shadow:
        0 0 0 3px rgba(34, 197, 94, 0.5),
        0 18px 40px rgba(0, 0, 0, 0.12);
}

.textarea-container textarea:focus {
    box-shadow:
        0 0 0 3px rgba(239, 68, 68, 0.5),
        0 18px 40px rgba(0, 0, 0, 0.12);
}

.editor-label {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 8px;
  opacity: 0.95;
  letter-spacing: 0.02em;
  transform: rotate(-1.5deg);
  margin-left: 8px;
  text-transform: uppercase;
}

.editor-label.green {
  color: #15803d;
}

.editor-label.red {
  color: #b91c1c;
  transform: rotate(1.2deg);
}

.editor {
  box-shadow:
    0 0 0 3px rgba(34, 197, 94, 0.35),
    0 0 0 6px rgba(34, 197, 94, 0.15),
    0 18px 40px rgba(0, 0, 0, 0.12);
}

.textarea-container textarea {
  box-shadow:
    0 0 0 3px rgba(239, 68, 68, 0.35),
    0 0 0 6px rgba(239, 68, 68, 0.15),
    0 18px 40px rgba(0, 0, 0, 0.12);
}

textarea {
    resize: vertical;
}

.tag {
  border-radius: 999px;
  padding: 3px 8px;
  font-weight: 600;
  font-size: 0.85em;
  box-shadow:
    inset 0 -1px 0 rgba(0,0,0,0.15),
    0 2px 6px rgba(0,0,0,0.15);
  transform: rotate(-0.5deg);
}

.tags {
    margin-top: 16px;
    width: 100%;
    background: rgba(255, 255, 255, 0.9);
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    border: 1px solid rgba(0,0,0,0.05);
}

.tags h4 {
    margin-top: 0;
    margin-bottom: 16px;
    font-size: 1.25rem;
    font-weight: 600;
}

.settings-section {
    display: flex;
    flex-direction: column;
    margin-top: 24px;
    width: 100%;
}

.tag-row {
  display: flex;
  gap: 12px;
  margin-bottom: 8px;
  align-items: center;
}

#settingsButton {
    background-color: transparent;
    color: #18181b;
    padding: 8px;
    width: 40px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 8px;
    border: 1px solid #e4e4e7;
    align-self: flex-end; /* Align button to the right */
    transition: all 0.2s ease;
}

#settingsButton:hover {
    background-color: #f4f4f5;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.hidden {
    display: none;
}

#tag-table-container table {
    width: 100%;
    border-collapse: collapse;
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    border: 1px solid #e4e4e7;
}

#tag-table-container th, #tag-table-container td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #e4e4e7;
}

#tag-table-container tr:last-child td {
    border-bottom: none;
}

#tag-table-container th {
    font-weight: 500;
    font-size: 0.9em;
    color: #71717a;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom-width: 1px;
}

#tag-table-container td:last-child, #tag-table-container th:last-child {
    text-align: right;
}

#tag-table-container input {
    width: 100%;
    padding: 8px;
    border: 1px solid #e4e4e7;
    border-radius: 4px;
    transition: border-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

#tag-table-container input:focus {
    border-color: #ef4444;
    outline: none;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

#tag-table-container .delete-button {
    background-color: transparent;
    color: #71717a;
    padding: 4px;
    font-size: 1.2rem;
    width: 32px;
    height: 32px;
    line-height: 32px;
    border-radius: 4px;
}

#tag-table-container .delete-button:hover {
    background-color: #fef2f2;
    color: #ef4444;
}

.textarea-container {
    position: relative;
}

.loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border: 4px solid #f3f3f3;
    border-top: 4px solid #ef4444;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

.tag-actions {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 16px;
    gap: 8px;
}

.tag-actions button {
    background-color: #f4f4f5;
    color: #18181b;
    border: 1px solid #e4e4e7;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 0.01em;
}

.tag-actions button:hover {
    background-color: #e4e4e7;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

button {
    background-color: #ef4444;
    color: #fff;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    letter-spacing: 0.02em;
}

button:hover {
    background-color: #dc2626;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

button:active {
    transform: translateY(0);
}

select { 
    margin-left: 8px;
    padding: 8px 12px;
    border-radius: 4px;
    border: 1px solid #e4e4e7;
}

.shake {
    animation: shake 0.5s;
    animation-iteration-count: infinite;
}

.popup {
    position: absolute;
    background: rgba(255,255,255,0.98);
    backdrop-filter: blur(12px);
    border-radius: 12px;
    box-shadow:
      0 20px 40px rgba(0,0,0,0.15),
      0 0 0 1px rgba(0,0,0,0.05);
    padding: 12px;
    z-index: 100;
    transition: all 0.2s ease;
    border: 1px solid rgba(0,0,0,0.1);
}

#popup-content {
    display: flex;
    flex-direction: column;
}

#popup-content button {
    margin-bottom: 4px;
    background-color: transparent;
    color: #18181b;
    text-align: left;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: background-color 0.2s ease;
}

#popup-content button:hover {
    background-color: #f4f4f5;
}


@keyframes shake {
    0% { transform: translate(1px, 1px) rotate(0deg); }
    10% { transform: translate(-1px, -2px) rotate(-1deg); }
    20% { transform: translate(-3px, 0px) rotate(1deg); }
    30% { transform: translate(3px, 2px) rotate(0deg); }
    40% { transform: translate(1px, -1px) rotate(1deg); }
    50% { transform: translate(-1px, 2px) rotate(-1deg); }
    60% { transform: translate(-3px, 1px) rotate(0deg); }
    70% { transform: translate(3px, 1px) rotate(-1deg); }
    80% { transform: translate(-1px, -1px) rotate(1deg); }
    90% { transform: translate(1px, 2px) rotate(0deg); }
    100% { transform: translate(1px, -2px) rotate(-1deg); }
}
