html, body {
  height: 100%;
}

body {
  font-family: 'Poppins', sans-serif;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: #f8f9fa;
  color: #333;
}
body.dark {
  background: #222;
  color: #eee;
}

#mode-toggle {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: inherit;
}

.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 1rem;
  height: 56px;
  background: #ff533d;
  color: #fff;
}
body.dark .navbar {
  background: #ff533d;
}
.nav-title {
  font-weight: 500;
  font-size: 1.2rem;
}

h1 {
  text-align: center;
  margin: 1rem 0;
}

main {
  flex: 1;
  padding: 0 1rem 1rem;
}

#welcome-msg {
  color: #444;
  font-size: 16px;
  text-align: center;
}

.tools {
  display: flex;
  gap: 16px;
  padding: 16px;
  overflow-x: auto;
  justify-content: center; /* center cards on large screens */
  flex-wrap: wrap;
}

@media (max-width: 767px) {
  .tools {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    overflow-x: visible;
  }

  .tool-card {
    flex: none;
  }
}
.tool-card {
  background: #fff;
  padding: 16px;
  margin: 0;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  transition: transform 0.2s, box-shadow 0.3s, border-color 0.3s, opacity 0.3s;
  cursor: pointer;
  text-align: center;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}
body.dark .tool-card {
  background: #444;
  box-shadow: 0 2px 4px rgba(0,0,0,0.4);
}
.tool-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  transform: scale(1.05);
}
.tool-card.selected {
  border: 1.5px solid #ff533d;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  background: #f0f8ff;
}
.tool-card.dim {
  opacity: 0.5;
}

.tool-section {
  margin: 1.5rem auto;
  max-width: 600px;
  background: #fff;
  border: 1px solid #e0e0e0;
  padding: 2rem;
  border-radius: 12px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
body.dark .tool-section {
  background: #444;
  border-color: #555;
}

.tool-section > * + * {
  margin-top: 1rem;
}

.tool-section h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 500;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #e0e0e0;
  align-self: stretch;
}
body.dark .tool-section h2 {
  border-color: #555;
}

.howto {
  background: #f1f5f9;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  font-size: 0.9rem;
  color: #333;
  display: flex;
  align-items: flex-start;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  align-self: stretch;
}
.howto::before {
  content: "\2139\FE0F";
  margin-right: 0.5rem;
}
body.dark .howto {
  background: #555;
  color: #eee;
}

.hidden {
  display: none;
}


footer {
  background: #fff;
  border-top: 1px solid #ddd;
  padding: 1rem;
  text-align: center;
  color: #666;
  flex-shrink: 0;
}
body.dark footer {
  background: #333;
  border-color: #444;
  color: #aaa;
}
.footer-links {
  list-style: none;
  display: flex;
  gap: 12px;
  justify-content: center;
  padding: 0;
  margin: 0 0 0.5rem 0;
}
.footer-links a {
  color: inherit;
  text-decoration: none;
}

/* tool forms */

.tool-section label {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  gap: 0.25rem;
  font-size: 0.95rem;
}

.tool-section input[type="text"],
.tool-section input[type="number"],
.tool-section input[type="range"],
.tool-section select {
  padding: 0.45rem 0.6rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 1rem;
  width: 100%;
  box-sizing: border-box;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.05);
  background: #fff;
  margin: 0;
  color: inherit;
}

body.dark .tool-section input[type="text"],
body.dark .tool-section input[type="number"],
body.dark .tool-section input[type="range"],
body.dark .tool-section select {
  background: #555;
  border-color: #666;
  color: #fff;
}

.tool-section button,
.tool-section a {
  background: #007bff;
  color: #fff;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  margin-right: 0.5rem;
}
.tool-section button:last-child,
.tool-section a:last-child {
  margin-right: 0;
}
.tool-section button:hover,
.tool-section a:hover {
  background: #0069d9;
}

.tool-section a {
  display: inline-block;
}

canvas {
  max-width: 100%;
  border: 1px solid #ccc;
}

body.dark canvas {
  border-color: #666;
}

/* custom file input drop zone */
.file-drop {
  border: 2px dashed #bbb;
  padding: 1.5rem;
  border-radius: 8px;
  text-align: center;
  cursor: pointer;
  color: #666;
  transition: background 0.2s, border-color 0.2s;
}
.file-drop:hover {
  background: #f8f9fa;
  border-color: #ff533d;
}
body.dark .file-drop:hover {
  background: #333;
}
.file-drop.dragover {
  background: #e6f7ff;
  border-color: #007bff;
}
.file-drop input {
  display: none;
}

/* preview thumbnails */
.preview-container {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  justify-content: center;
  margin-top: 1rem;
}

@media (max-width: 767px) {
  .preview-container {
    grid-template-columns: repeat(2, 1fr);
  }
}
.preview-item {
  position: relative;
  width: 100%;
  border: 1px solid #ddd;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
  overflow: hidden;
  background: #fff;
  text-align: center;
  transition: box-shadow 0.2s, transform 0.2s;
  animation: fadeIn 0.3s ease;
}
.preview-item:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  transform: translateY(-2px);
}
.preview-item img {
  width: 100%;
  height: 100px;
  object-fit: cover;
  display: block;
}
.preview-item span {
  display: block;
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.remove-preview {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(0,0,0,0.5);
  border: none;
  color: #fff;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  transition: background 0.2s;
}
.remove-preview:hover {
  background: rgba(0,0,0,0.7);
}
body.dark .preview-item {
  background: #555;
  border-color: #666;
}
body.dark .remove-preview {
  background: rgba(255,255,255,0.3);
  color: #fff;
}
.size-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%,-50%);
  background: rgba(0,0,0,0.6);
  color: #fff;
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 0.75rem;
  pointer-events: none;
}

.file-count {
  text-align: center;
  margin-top: 0.5rem;
  font-size: 0.9rem;
  color: #666;
}
body.dark .file-count {
  color: #ccc;
}

.file-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 0.5rem;
}
.file-actions button {
  padding: 0.35rem 0.9rem;
  border: none;
  color: #fff;
  cursor: pointer;
  border-radius: 4px;
}
.file-actions .add-btn {
  background: #007bff;
}
.file-actions .add-btn:hover {
  background: #0069d9;
}
.file-actions .clear-btn {
  background: #6c757d;
}
.file-actions .clear-btn:hover {
  background: #5a6268;
}

.progress-flow {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 1rem;
}
.progress-flow .step {
  background: #eee;
  color: #555;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.9rem;
}
body.dark .progress-flow .step {
  background: #555;
  color: #ddd;
}
.progress-flow .step.active {
  background: #007bff;
  color: #fff;
}

.compress-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

@keyframes fadeIn {
  from {opacity: 0;}
  to {opacity: 1;}
}

.download-links a {
  display: inline-block;
  margin: 0.25rem;
  background: #28a745;
  color: #fff;
  padding: 0.4rem 0.75rem;
  border-radius: 4px;
  text-decoration: none;
  font-size: 0.9rem;
}
.download-links a:hover {
  background: #218838;
  text-decoration: none;
}


/* crop results */
.crop-results {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  margin-top: 1rem;
}
.crop-item {
  position: relative;
  width: 160px;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 0.5rem;
  background: #fff;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.crop-item img {
  width: 100%;
  height: 150px;
  object-fit: contain;
  display: block;
  border-radius: 4px;
}
.close-crop {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(0,0,0,0.5);
  color: #fff;
  border: none;
  border-radius: 50%;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:14px;
  width: 20px;
  height: 20px;
  cursor: pointer;
  line-height: 1;
}
.crop-download {
  display: inline-block;
  margin-top: 0.5rem;
  background: #28a745;
  color: #fff;
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  text-decoration: none;
  font-size: 0.85rem;
}
.crop-download:hover {
  background: #218838;
}
body.dark .crop-item {
  background: #555;
  border-color: #666;
}
body.dark .close-crop {
  background: rgba(255,255,255,0.3);
  color: #fff;
}
.result-container {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  margin-top: 1rem;
}
.result-item {
  position: relative;
  width: 160px;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 0.5rem;
  background: #fff;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.result-item img {
  width: 100%;
  height: 150px;
  object-fit: contain;
  display: block;
  border-radius: 4px;
}
.close-result {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(0,0,0,0.5);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: pointer;
  line-height: 1;
}
.result-download {
  display: inline-block;
  margin-top: 0.5rem;
  background: #28a745;
  color: #fff;
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  text-decoration: none;
  font-size: 0.85rem;
}
.result-download:hover {
  background: #218838;
}
body.dark .result-item {
  background: #555;
  border-color: #666;
}
body.dark .close-result {
  background: rgba(255,255,255,0.3);
  color: #fff;
}


.watermark-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  width: 100%;
}

/* Other Tools section */
.other-tools-section {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0.5rem;
}

.other-tools-section h2 {
  text-align: center;
  margin-bottom: 0.5rem;
  font-size: 1.2rem;
}

.other-tools {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.other-card {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  padding: 12px;
  flex: 1 1 260px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

body.dark .other-card {
  background: #444;
  box-shadow: 0 2px 4px rgba(0,0,0,0.4);
}

.other-card h3 {
  margin: 0 0 0.25rem;
  font-size: 1rem;
}

.other-card p {
  margin: 0 0 1rem;
  flex: 1;
}

.other-card a,
.other-card button {
  background: #FF5A3C;
  color: #fff;
  border: none;
  padding: 0.4rem 0.9rem;
  border-radius: 4px;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.25s, box-shadow 0.25s;
}

.other-card a:hover,
.other-card button:hover {
  background: #e14a31;
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.other-card button:disabled {
  background: #ccc;
  cursor: not-allowed;
}

body.dark .other-card button:disabled {
  background: #666;
}

.card-icon {
  font-size: 2rem;
  margin-bottom: 0.25rem;
}


.seo-desc {
  margin: 0 0 1rem;
  text-align: left;
  font-size: 1rem;
  color: #666;
}

.seo-desc:last-child {
  margin-bottom: 0;
}

body.dark .seo-desc {
  color: #ccc;
}

.seo-block {
  position: relative;
  max-width: 800px;
  margin: 1.5rem auto;
  padding-left: calc(1rem + 15px);
  padding-right: 1rem;
}

.seo-block::before {
  content: "";
  position: absolute;
  left: 1rem;
  top: 0;
  bottom: 0;
  width: 3px;
  border-radius: 3px;
  background: #FF5A3C;
}

.section-divider {
  border: none;
  border-top: 1px solid #ddd;
  margin: 2rem auto 1rem;
  width: 90%;
}

body.dark .section-divider {
  border-color: #555;
}
