:root {
  --bg: #f1f1f1;
  --surface: #ffffff;
  --text: #1f1f1f;
  --muted: #666666;
  --line: #dcdcdc;
  --line-soft: #e8e8e8;
  --primary: #4a63f3;
  --primary-hover: #3d54d1;
  --dark: #2f3136;
  --container: 860px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Montserrat', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button { cursor: pointer; }

.container {
  width: min(100% - 32px, var(--container));
  margin: 0 auto;
}

/* Header */
.site-header { background: var(--dark); color: #fff; }
.header-inner {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-size: 20px; font-weight: 700; }
.brand-logo {
  width: 34px; height: 34px; background: #11a8ff; color: #fff;
  border-radius: 6px; display: inline-flex; align-items: center;
  justify-content: center; font-size: 12px; font-weight: 700;
}
.main-nav { display: flex; align-items: center; gap: 18px; }
.main-nav a { color: #fff; font-size: 14px; font-weight: 600; }
.menu-toggle {
  display: none; width: 42px; height: 42px; padding: 0;
  border: 1px solid rgba(255,255,255,0.18); background: transparent;
  border-radius: 4px; align-items: center; justify-content: center;
  flex-direction: column; gap: 5px;
}
.menu-toggle span { display: block; width: 18px; height: 2px; background: #fff; border-radius: 999px; }

/* Hero */
.hero-section { padding: 32px 0 14px; }
.hero-inner h1 { margin: 0 0 10px; font-size: 42px; line-height: 1.15; }
.hero-text { margin: 0; color: var(--muted); font-size: 16px; }

/* Tool */
.tool-section { padding: 8px 0 26px; }
.tool-card { background: var(--surface); border: 1px solid var(--line); }

.upload-area {
  margin: 22px;
  min-height: 250px;
  border: 3px dashed var(--line-soft);
  background: #fafafa;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
}
.upload-area.dragover { background: #f4f7ff; border-color: #bcc8ff; }
.upload-content p { margin: 8px 0; color: var(--muted); font-size: 14px; }
.upload-note { max-width: 360px; margin: 12px auto 0; line-height: 1.5; }

/* Buttons */
.primary-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 56px; padding: 0 28px; border: 0;
  background: var(--primary); color: #fff; font-weight: 700; border-radius: 4px;
}
.primary-btn:hover { background: var(--primary-hover); }
.primary-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.secondary-btn {
  min-height: 46px; padding: 0 18px;
  border: 1px solid var(--line); background: #f4f4f4;
  color: var(--text); font-weight: 700; border-radius: 4px;
}

/* Preview */
.preview-box, .result-card {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 18px;
}
.preview-box, .size-box, .mode-box, .status-box, .result-box {
  margin: 0 22px 22px;
}
.preview-image-wrap {
  aspect-ratio: 1 / 1;
  border: 1px solid var(--line);
  background: #fafafa;
  display: flex; align-items: center; justify-content: center;
}
.preview-image-wrap img { width: 100%; height: 100%; object-fit: contain; }

.preview-info h2, .size-box h2, .mode-box h2, .result-box h2 {
  margin: 0 0 12px; font-size: 20px;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.info-item { border: 1px solid var(--line); background: #fff; padding: 12px; }
.info-label { display: block; margin-bottom: 4px; font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--muted); }
.info-value { display: block; font-size: 14px; font-weight: 700; word-break: break-word; }

/* Size select */
.size-box {
  border-top: 1px solid var(--line);
  padding-top: 22px;
}

.size-select-wrap {
  position: relative;
}

.size-select-wrap select {
  width: 100%;
  max-width: 480px;
  height: 48px;
  padding: 0 40px 0 14px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  appearance: none;
  cursor: pointer;
}

.size-select-wrap select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(74, 99, 243, 0.12);
}

.size-select-wrap::after {
  content: '';
  position: absolute;
  right: calc(100% - 460px);
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--muted);
  pointer-events: none;
}

/* Mode buttons */
.mode-box {
  border-top: 1px solid var(--line);
  padding-top: 22px;
}

.mode-buttons {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.mode-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-width: 200px;
  padding: 14px 18px;
  border: 2px solid var(--line);
  background: #fff;
  border-radius: 6px;
  color: var(--text);
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}

.mode-btn:hover { border-color: var(--primary); background: #f4f7ff; }
.mode-btn.active { border-color: var(--primary); background: #f0f3ff; }
.mode-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.mode-btn-title {
  font-size: 15px;
  font-weight: 700;
}

.mode-btn-desc {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

/* Status */
.status-box {
  padding: 16px;
  background: #f7f9fc;
  border: 1px solid var(--line);
  border-radius: 4px;
}
.loader-line {
  width: 100%; height: 6px; background: #e6e8ef;
  border-radius: 6px; overflow: hidden; margin-bottom: 12px;
}
.loader-bar {
  display: block; width: 0%; height: 100%;
  background: linear-gradient(90deg, #4f6df5, #6a82fb);
  border-radius: 6px; transition: width 0.35s ease;
}
.status-box p { margin: 0; color: #49556a; font-size: 14px; font-weight: 600; }

/* Result */
.result-box { border-top: 1px solid var(--line); padding-top: 22px; }
.result-actions, .new-resize-row { margin-top: 18px; }

/* Content */
.content-section { padding: 0 0 46px; }
.content-inner { background: #fff; border: 1px solid var(--line); padding: 22px; }
.content-inner h2 { margin: 0 0 12px; font-size: 24px; }
.content-inner h2 + h2 { margin-top: 24px; }
.content-inner p { margin: 0; color: var(--muted); font-size: 15px; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(16,18,27,0.68);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; z-index: 99999;
}
.modal-box {
  width: min(100%, 460px); background: #fff; border: 1px solid #e6e8ef;
  border-radius: 10px; padding: 24px; position: relative;
  box-shadow: 0 20px 60px rgba(0,0,0,0.18);
}
.modal-box h2 { margin: 0 0 10px; font-size: 22px; }
.modal-box p { margin: 0; color: var(--muted); line-height: 1.6; font-size: 15px; }
.modal-actions { margin-top: 18px; }
.modal-btn { min-height: 46px; padding: 0 18px; border: 0; background: var(--primary); color: #fff; font-weight: 700; border-radius: 4px; }
.modal-btn:hover { background: var(--primary-hover); }
.modal-close {
  position: absolute; top: 10px; right: 10px; width: 36px; height: 36px;
  border: 1px solid var(--line); background: #fff; border-radius: 6px;
  font-size: 22px; line-height: 1; display: inline-flex; align-items: center;
  justify-content: center; cursor: pointer;
}
.modal-close:hover { background: #f5f6fa; }
.hidden { display: none !important; }

/* Footer */
.site-footer {
  background: #2f3136; color: #cbd5f5;
  padding: 50px 20px 30px; margin-top: 60px;
}
.footer-container {
  max-width: 1200px; margin: auto;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 40px;
}
.footer-column h4 { color: #fff; margin-bottom: 15px; font-size: 16px; }
.footer-column p { font-size: 14px; line-height: 1.6; }
.footer-column ul { list-style: none; padding: 0; margin: 0; }
.footer-column li { margin-bottom: 8px; }
.footer-column a { color: #cbd5f5; text-decoration: none; font-size: 14px; }
.footer-column a:hover { color: #fff; }
.footer-bottom {
  text-align: center; margin-top: 40px; font-size: 13px;
  border-top: 1px solid rgba(255,255,255,0.08); padding-top: 20px;
}

/* Responsive */
@media (max-width: 860px) {
  .preview-box, .result-card { grid-template-columns: 1fr; }
  .info-grid { grid-template-columns: 1fr; }
  .preview-image-wrap { max-width: 220px; }
  .size-select-wrap::after { right: 14px; }
}

@media (max-width: 700px) {
  .header-inner {
    min-height: auto; padding: 14px 0;
    display: grid; grid-template-columns: 1fr auto;
    align-items: center; gap: 14px;
  }
  .menu-toggle { display: inline-flex; }
  .main-nav {
    display: none; grid-column: 1 / -1; width: 100%;
    flex-direction: column; align-items: flex-start; gap: 12px; padding-top: 6px;
  }
  .main-nav.is-open { display: flex; }
  .hero-inner h1 { font-size: 30px; }
  .upload-area { margin: 16px; padding: 32px 16px; min-height: 220px; }
  .preview-box, .size-box, .mode-box, .status-box, .result-box { margin-left: 16px; margin-right: 16px; }
  .mode-btn { min-width: 100%; }
  .size-select-wrap select { max-width: 100%; }
  .size-select-wrap::after { right: 14px; }
}

.content-inner a {
  color: #2f6fed;
  text-decoration: none;
  font-weight: 600;
}

.content-inner a:hover {
  color: #1d4ed8;
  text-decoration: underline;
}
